Closed (fixed)
Project:
Privatemsg
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Jun 2010 at 07:57 UTC
Updated:
4 Feb 2011 at 13:10 UTC
Jump to comment: Most recent file
mysql> EXPLAIN SELECT COUNT(DISTINCT thread_id) as unread_count FROM pm_index pmi WHERE (pmi.deleted = 0) AND (pmi.is_new = 1) AND (pmi.uid = 11);
+----+-------------+-------+------+---------------+------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+-------+------+-------------+
| 1 | SIMPLE | pmi | ref | uid | uid | 4 | const | 2592 | Using where |
+----+-------------+-------+------+---------------+------+---------+-------+------+-------------+
1 row in set (0.00 sec)
An index on deleted, is_new, uid ought to solve it.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | update_indexes_and_notices_fixed.patch | 5.9 KB | berdir |
| #2 | update_indexes.patch | 3.69 KB | berdir |
Comments
Comment #1
berdirUh oh, catch is looking at my queries :)
Yeah, you're right, confirmed this on my setup. Will write a patch soon...
Comment #2
berdirOk, I took the opportunity and looked through most of our queries.
Turned out that most of our indexes aren't used at all, so I tried to optimize the indexes and this is what I came up with.
For the reference, these are the queries which I used for testing (first the index and then the queries which are improved by that index):
The patches updates the hook_schema() definition for those 4 tables and also provides an update function.
Comment #4
berdirAhh, now I got it ;)
Simpletest does not display notices for D6 too... ;)
The attached patch should now pass.
Comment #5
catchPatch looks good, I'll test it in the next day or so.
Comment #6
berdirTried the upgrade path on a clean install of privatemsg 6.x-1.x-dev and it worked fine. So I've decided to commit this. As said before, this needs to be done for 6.x-2.x to before it gets stable but it doesn't make much sense now.
Comment #7
berdirI've recently updated the tables for 7.x-1.x, see #968384: Error when upgrading to 2.x-dev version for 6.x-2.x.