in reply to Re^3: DBI performance problem with MySQL
in thread DBI performance problem with MySQL
O esteemed saint, when I turn on DBI trace (even at maximum level), the only query I see is the one sent to prepare(), which has placeholders. (Can't execute EXPLAIN on it). But say I fill in those placeholders with string datetimes:
EXPLAIN SELECT logic_id, since, till FROM COND_dummy WHERE logic_id = 9999 AND ((since >= '2005-01-01 00:00:00' AND since < '2005-01-01 00:00:01') OR (till > '2005-01-01 00:00:00' AND till < '2005-01-01 00:00:01') OR ('2005-01-01 00:00:00' >= since AND '2005-01-01 00:00:01' < till)) + LIMIT 1;
It says that it is using my indexes.
+----+-------------+------------+------+---------------+---------+---------+-------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+------------+------+---------------+---------+---------+-------+------+--------------------------+ | 1 | SIMPLE | COND_dummy | ref | PRIMARY,IoV | PRIMARY | 4 | const | 1 | Using where; Using index | +----+-------------+------------+------+---------------+---------+---------+-------+------+--------------------------+
And just to test the theory that it has something to do with DATETIME and VARCHARS and conversions at all, I changed the DATETIME columns to INT and ran the script again. Exact same behavior. In fact, somehow, using INTs for the since, till columns made everything slower!
[#insert] [date time] [ins/s] 1000 2005-03-09 10:58:10 649.516 2000 2005-03-09 10:58:14 287.810 3000 2005-03-09 10:58:19 212.805 4000 2005-03-09 10:58:26 136.577 5000 2005-03-09 10:58:34 118.965 6000 2005-03-09 10:58:45 94.537 7000 2005-03-09 10:58:57 84.296 8000 2005-03-09 10:59:10 74.197 9000 2005-03-09 10:59:26 64.026 10000 2005-03-09 10:59:44 54.799
It is a mystery.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: DBI performance problem with MySQL
by dragonchild (Archbishop) on Mar 09, 2005 at 19:03 UTC | |
by e2ka (Acolyte) on Mar 09, 2005 at 19:20 UTC |