Title: Bug on LIMIT queries
Last modified: August 21, 2016

---

# Bug on LIMIT queries

 *  [Marco Chiesi](https://wordpress.org/support/users/marcochiesi/)
 * (@marcochiesi)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/bug-on-limit-queries/)
 * It looks like setting limit for search queries does not work. It depends on the
   way the plugin handles pattern recognition, which is made via PHP and not via
   MySQL. This way, record limitation should be done at PHP level and not by adding
   a LIMIT clause to the SQL queries, otherwise it will search on a small subset
   of the DB.
    The problem occurs for sure on “post content” and “post meta value”
   searches, but it probably affetcts also other types of searches. I managed to
   correct this wrong behavior on my own, but I would be glad if it would be fixed
   in next versions. By the way, I removed LIMIT from SQL queries, and I added the
   following snippet just before the return of the find methods:
 *     ```
       if ($limit > 0) {
       	$results = array_slice($results, $offset, $limit);
       }
       ```
   
 * [https://wordpress.org/plugins/search-regex/](https://wordpress.org/plugins/search-regex/)

Viewing 1 replies (of 1 total)

 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/bug-on-limit-queries/#post-4946270)
 * Just hit this on post_meta searches. Plus for some reason if i use “no limit”
   I get nothing back but if I hack in a $limit=100000 I get back the 46k results(
   I have a lot of post_meta!) I was after checking through

Viewing 1 replies (of 1 total)

The topic ‘Bug on LIMIT queries’ is closed to new replies.

 * ![](https://ps.w.org/search-regex/assets/icon-256x256.jpg?rev=1030025)
 * [Search Regex](https://wordpress.org/plugins/search-regex/)
 * [Support Threads](https://wordpress.org/support/plugin/search-regex/)
 * [Active Topics](https://wordpress.org/support/plugin/search-regex/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/search-regex/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/search-regex/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [alanft](https://wordpress.org/support/users/alanft/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/bug-on-limit-queries/#post-4946270)
 * Status: not resolved