Jump to content

Recommended Posts

I have a table with about 5000 records in it and roughly 50 fields, all with a lot of data in them.

Naturally you can search in that table, but sometimes the results seem to be more then SQL can handle, the limit seems to be around 2000 records.

Its not a question of getting the information, but having 2000 times an "OR id = '$id'" in the query.

Right now I can't think of an alternative to get all the possible returned records, since it could be anywhere between zero and 5000.

 

Any ways to get all the record id's without overloading the query with OR's?

Link to comment
https://forums.phpfreaks.com/topic/49462-search-overload/
Share on other sites

ORs are expensive.  First simply make sure you have indexes on the fields you're searching, and unique indexes where possible.  That'll help the database find records faster.  For such a small set of data this might suffice.  Also don't use LIKE conditionals unless you have to, and if you do try to not use a wildcard at the start of the field (i.e. LIKE 'smith%' instead of '%smith%').

 

If it's still too slow after all that, use the EXPLAIN statement and post the output of it here so we can investigate the details.

Link to comment
https://forums.phpfreaks.com/topic/49462-search-overload/#findComment-242432
Share on other sites

Its not the searching in the database that's the problem, its showing all the ids.

For instance, I could (in theory) have record 1,3,5,7,9 and then all the way to 5000.

The only way in which it could show all the ids then would be by using "OR id = '1' OR id = '3' etc".

 

I suppose I could do it differently, running a thousand queries with one id (using a loop) then one query with a thousand ids but I think that would be very slow loading.

Link to comment
https://forums.phpfreaks.com/topic/49462-search-overload/#findComment-247914
Share on other sites

Data base design is a job tytle!

 

It is not just putting 5,000 records and using select.

 

You can search all by a key word, subset key word, etc....

 

But if you want to have 1000 key words to search, why not break it down to 100 data bases of same date!

Link to comment
https://forums.phpfreaks.com/topic/49462-search-overload/#findComment-247929
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.