|
I want to create a filter of reputes for some period. A query is:
After that i ran
But this solution is very slow. Нow can I optimize the query? Maybe there are other ways (without using reputes table)? General task is to get users who have been reputed from one date to another. I've changed an
But the query has not working faster. Where the mistake? I've tried this one. I've run
For getting indexes. After I've run
I've put
into dbshell, but got an error
I also tried
How I understood the trouble in I've tried to create an other query
But I had the same result. How can I optimizing the query (a calculation of sum of the reputes values)? OK. I've gotten a generated query. In the query the Django platform has pasted GROUP BY by all columns in the query (there are about 15 columns). I think the problem in GROUP BY statement. What must I do for fix this trouble? |
The question has been closed for the following reason "The question is answered" by expert 16 Nov '11, 11:56
|
Just add some indexes on your database tables and things should work much faster. And the answer is the same. Its ok that query, but you can't go very far without adding some indexes. Django won't do it for you/OSQA, you need to add them yourself. Start by indexing the date columns and things should go much smoother.
(07 Nov '11, 16:55)
Hernani Cerq... ♦♦
You need to do them manually in the db. Just by adding them on the code, nothing changed. Here's docs for mysql: http://dev.mysql.com/doc/refman/5.0/en/create-index.html postgres: http://www.postgresql.org/docs/current/static/sql-createindex.html
(09 Nov '11, 10:07)
Hernani Cerq... ♦♦
You are trying to duplicate foreign keys and whatnot. Its not that hard to create an index (mysql sample):
(09 Nov '11, 10:42)
Hernani Cerq... ♦♦
I've created it, but the speed is same - very slow. Maybe need something else?
(09 Nov '11, 11:20)
expert
I tried your original query in this site and it ran instantly. Something is not correct in your setup if it is that slow.
(09 Nov '11, 15:58)
Hernani Cerq... ♦♦
On what kind of setups I must look? Maybe it depends on the size of the database (count of users and the reputes)? On different sets I've got different time.
(09 Nov '11, 16:32)
expert
The post was updated.
(10 Nov '11, 07:28)
expert
showing 5 of 7
show 2 more comments
|
|
I don't know, is it normal or not but my solution is working
It's fast and doesn't depend on size of database. If I have mistakes, please show them to me. |
Do anyone have any ideas?