Opened 4 years ago
Closed 11 months ago
#49479 closed enhancement (invalid)
Does $wpdb->get_row() add LIMIT 1 to the query?
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.3.2 |
Component: | Database | Keywords: | close |
Focuses: | performance | Cc: |
Description
I've been trying to investigate either $wpdb->get_row() adds a LIMIT 1 dynamically to the executed query, since it only returns 1 row. But couldn't find the LIMIT added anywhere in the code.
Does that mean that $wpdb->get_row() does not add LIMIT 1 dynamically to the query? If so, shouldn't it?
Change History (2)
Note: See
TracTickets for help on using
tickets.
Hi @lambasoft - Welcome to WordPress Trac.
To answer your question: No, it does not add a
.. LIMIT 1
clause to the query. It runs the query, and returns one result and that's it. I suppose addingLIMIT 1
would give a performance benefit, but thisget_row
is meant to be used on database structures that contains exactly one result or none (for example to load a user by a specific ID). To load multiple results, usewpdb::get_results
.