473,499 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Optimizer Penalty for using LIKE + ORDER BY + LIMIT ?

Ed
------=_NextPart_000_001D_01C34FCC.1D2B5E50
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

There seems to be a significant penalty imposed by the optimizer when =
these
3 clauses are uses together. If we use the Full Text Search the penalty =
is
gone. However, the Full Text Search is not a very good option in my =
case as
it does not offer the granularity needed.

=20

Please see below:

=20

Optimizer Penalty for using LIKE + ORDER BY + LIMIT

=20

a) Using Full Text Search

mysql> SELECT a.dvd_id FROM dvd a, dvd_search s WHERE a.dvd_id =3D =
s.dvd_id
and match (s.title) against ('breakfast' in boolean mode) ORDER BY
a.title_sort, a.director LIMIT 0,50;

10 rows in set (0.00 sec)

=20

b) Using LIKE -- a 2.30 seconds penalty

mysql> SELECT a.dvd_id FROM dvd a, dvd_search s WHERE a.dvd_id =3D =
s.dvd_id
and s.title like '% breakfast%' ORDER BY a.title_sort, a.director LIMIT
0,50;

10 rows in set (2.30 sec)

=20

c) Using LIKE, but removing the LIMIT - the penalty is gone

mysql> SELECT a.dvd_id FROM dvd a, dvd_search s WHERE a.dvd_id =3D =
s.dvd_id
and s.title like '% breakfast%' ORDER BY a.title_sort, a.director;

10 rows in set (0.10 sec)

=20

d) Using LIKE, but removing the ORDER BY - the penalty is gone

mysql> SELECT a.dvd_id FROM dvd a, dvd_search s WHERE a.dvd_id =3D =
s.dvd_id
and s.title like '% breakfast%' LIMIT 0,50;

10 rows in set (0.10 sec)

=20

e) Even when eliminating the second table from the query the penalty =
still
remains

mysql> SELECT a.dvd_id FROM dvd a WHERE a.title like '%breakfast%' ORDER =
BY
a.title_sort, a.director LIMIT 0,50;

10 rows in set (0.58 sec)

=20

Each table has about 32,000 rows and they are 260MB and 10MB in size
(data+index). The machine has 1GB of memory.

=20

I'm using 4.0.12. Unfortunately I'm unable to verify if this has been
corrected in 4.1.0 because of the SSL library compatibility -- I presume =
you
are aware of the libcrypto.so.0.9.6 and libssl.so.0.9.6 issue.

=20

Any help will be greatly appreciated.

=20

Thanks,

=20

Ed
------=_NextPart_000_001D_01C34FCC.1D2B5E50--
Jul 19 '05 #1
0 3078

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1579
by: Philip Yale | last post by:
I'm very puzzled by the choice of NC index being made by the optimizer in this example. I don't actually think it should use an NC index at all. I have: Table: CustomerStatus_T Single data...
8
1753
by: alex goldman | last post by:
class c { int x; public: inline c() : x(0) {} inline c(int i) { x = i; } inline operator const int& () const { return x; } inline operator int& () { return x; } };
1
1659
by: Tom Schindl | last post by:
Hi, the following Statement worked on MySQL 4.0 but after upgrading to 4.1.12 on win32 the order is not working any more. Is this a known problem or is our SQL simply not useable on 4.1 or is...
14
1945
by: Bupp Phillips | last post by:
I have a customer table that has the field CUSTOMER_ID as the primary key (cust_pkkey), the table has 102,834 records in it. The following select statement works fine: select * from customer...
1
1487
by: William M. Miller | last post by:
We've recently encountered a bug in the optimization of floating point computations inside loops. To summarize, the optimizer reorders floating point operations in a fashion that is not permitted...
6
1561
by: Ian Ribas | last post by:
Hello, This is probably a common problem, but I couldn't really find a direct answer in the archives (or maybe just couldn't find one that satisfied me ;-). I created an index specifically to...
0
1238
by: Rob K. | last post by:
I have a new summary table built againt a single data table. Simple select, count(*) and group by type. After I built it, I found that the optimizer will choose to use it for existing queries IF...
5
3034
by: Kevin | last post by:
Using a base table, a MQT table was created. With optimization - when querying the base table with calcuation that are already completed in the MQT - I would assume the optimizer would use the MQT...
4
2688
by: frenk_mo | last post by:
In a cobol program I have an SQL instruction like following: EXEC SQL DECLARE CURSORE_1 CURSOR FOR SELECT CAMPO1, CAMPO2, CAMPO3, CAMPO4, CAMPO5, CAMPO6, CAMPO7,
0
7132
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7009
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.