[EMAIL PROTECTED] wrote:
Ben Clewett <[EMAIL PROTECTED]> writes:


D. Richard Hipp wrote:

MySQL and PostgreSQL will use the indexes here, and therefore return the
result considerably faster.


Really?  I would be very interested to know what
query plan MySQL and PostgreSQL use in this example.

It looks like I didn't look before leaping. MySQL does do a sequential search through all rows in table with same example.

But PostgreSQL does use indexes for the same example.


You can get the PostgreSQL query plan by issuing this query:

EXPLAIN SELECT * FROM a WHERE f1 = 1 OR f2 = 1;

The output from that command is what Dr. Hipp requested.

Derrell

Ok,

From MySQL with 310606 rows:

+----+-------------+-------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | a | ALL | a_f1,a_f2 | NULL | NULL | NULL | 310606 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+--------+-------------+

From PSql with 2534 rows:

                               QUERY PLAN
-------------------------------------------------------------------------
 Index Scan using a_f1, a_f2 on a  (cost=0.00..39.86 rows=1003 width=12)
   Index Cond: ((f1 = 1) OR (f2 = 1))


Regards,


Reply via email to