Mysql hangs when trying to query table with many records (PHP)

Asked

Viewed 261 times

0

I am trying to make a filter where the query is done in a table where the id of the last record is in the number 468.466.

In the filter, I need to make a comparison with a View, which has your id from the last record 5.303.345.

The query is the following:

SELECT * FROM tb_name1
left join tb_name2 using (id)

When trying to do it, it stays long charging and does not finish, because it even locks my whole computer, I need to restart it on the button.

Any solution for me to be able to run this filter?

  • 1

    How about paging? Why do you need so many records at once?

  • Ids don’t mean much, you may have deleted table 1 and started from 468465, right? but are you sure you want to return all this of records? can’t test first using a limit or any condition in the where? assuming that the view actually has 5+million records, this Join will take even, but should not be enough to lock. Incidentally, when using using for Join, make sure the two tables use id as key (primary and foreign)?

  • Okay, I can set the limit. But I need to list the data... What do I do with the rest that wasn’t listed? Yes, I gave a Count and the table has almost 200,000 records. That’s a lot. It’s okay that there’s a field for searching. I could list some and leave the rest for research.

  • But do you need all the records at once? Why? To page, you only need to work with limit and offset, showing each page of records at a time, as required.

  • Yes. If I show each page at a time, I need to create an instruction in my code to show on the next page, always 1 record from the last of the previous page, right?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.