Opened 7 years ago
Closed 4 years ago
#49479 closed enhancement (invalid)
Does $wpdb->get_row() add LIMIT 1 to the query?
| Reported by: | lambasoft | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Database | Version: | 5.3.2 |
| Severity: | normal | Keywords: | close |
| Cc: | Focuses: | performance |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi @lambasoft - Welcome to WordPress Trac.
To answer your question: No, it does not add a
.. LIMIT 1clause to the query. It runs the query, and returns one result and that's it. I suppose addingLIMIT 1would give a performance benefit, but thisget_rowis 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.