When i am filtering mysql results using php programming, the webpage is taking too much time to load (approx 30-40 secs) when results are getting more than 1000. How can i reduce the loading time to as minimum as i can ?
Asked
Active
Viewed 170 times
0
-
I am using join queries – Killer Hacker Oct 28 '15 at 10:16
-
Joins obviously slows the query – Harshit Oct 28 '15 at 10:17
-
@HarshitShrivastava Thats not true at all. In fact, if the table is big it actually speeds up the query in most cases since it doesn't have to look through as much data – Crecket Oct 28 '15 at 10:21
-
@Crecket yes you are right – Killer Hacker Oct 28 '15 at 10:22
3 Answers
0
If your query use a WHERE clause, you might want to index your table on the columns used as WHERE criteria to allow faster retrieval.
-
Yes i am using WHERE clause in my query, so can you add a simple indexing example of query ? – Killer Hacker Oct 28 '15 at 10:20
-
-
-
0
What about using views? The view will be updated and have the latest data. Then you select *
from the view rather than joining on the original table.
As per other answers, indexing on the fields you use for filtering and joining should speed up the process. These are also nice to have when you are using views (they will update faster).
Finally, try to do everything in the database, ie do not loop the results in PHP.

urban
- 5,392
- 3
- 19
- 45
0
If you want only limited results (that can save time), then use
select * from table as RANDOM LIMIT 500

Thomas N T
- 459
- 1
- 3
- 14