Skip to content
Advertisement

Query can not be executed, or waiting too long


I am using MySQL 5.0 and working with some crowded tables. I actually want to calculate something and
wrote a query like this:

Well, there are 3 tables here and have approx. 60,000 rows per table. Is it taking too long because tables are so crowded (so should I transfer to NoSQL or sth) or it is a normal query but my server is taking too long because its CPU is weak? Or my query is wrong?

I want this query to sum all price columns from three tables and found which user spent the most money.


Thanks for your time 🙂

Advertisement

Answer

It looks like your query is Ok. You have to check whether there are indexes present on these three tables or not. Please create indexes like-

Above statements will create non-clustered indexes on payment_user column.

if payment_user data type is BLOB/Text then –

In above statements, I have set prefix length to 100. You have to decide this prefix length as per your data.

From MySQL documentation:

BLOB and TEXT columns also can be indexed, but a prefix length must be given.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement