473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

mySQL 4.02 - select statement on non primary field takes incredibly longtime - why ?

Dear mySQL community,
I have once again turned to the user groups for a problem I cannot
solve myself! Atually, I have read all I can from the newsgroups on
this but I could not solve it myself.
Here it is:
mySQL server: version "4.0.20-standard" on localhost
hardware : 1.8 MHz Pentium 4 with 512 cache and 512 MB 266MHz RAM and
40 MB Matrox+ harddisk

Here is the problem:
There is a table which I has 7 fields, 3000 records. One field is
auto_number and is PRIMARY, second is an integer(12) field and is KEY,
and the rest are varchar(255) fields. - This is the OLDTABLE
I have created a new table, and repeated the table I just described
over and over into this new table, there are now more than 3.6 million
records. - This is the new NEWTABLE
When I run a select like "select * from NEWTABLE where
auto_number="BLAHBLAH" it returns the record in miliseconds.
But when I query the integer(12) field "SELECT dnjNo FROM NEWTABLE
where dnjNo='$dnjno' limit 25", it takes 2 and half minutes to tell me
if the record does not exist, but only if does not exist, if it
exists, then the 25 rows are returned in about 3 seconds and then in
0.2 seconds for subsequent search.
Why does it take so long to tell me if a record does not exist?
Any suggestions on how I can improve this performance, since without
this how can I basically search for non-existant rows? Did I forget to
say that the CPU is running at full during the 2 and half minute.
Please help!
ghasem
Jul 20 '05 #1
2 2451
gh************@yahoo.com (ghasem) wrote in message news:<e9**************************@posting.google. com>...
Dear mySQL community,
I have once again turned to the user groups for a problem I cannot
solve myself! Atually, I have read all I can from the newsgroups on
this but I could not solve it myself.
Here it is:
mySQL server: version "4.0.20-standard" on localhost
hardware : 1.8 MHz Pentium 4 with 512 cache and 512 MB 266MHz RAM and
40 MB Matrox+ harddisk

Here is the problem:
There is a table which I has 7 fields, 3000 records. One field is
auto_number and is PRIMARY, second is an integer(12) field and is KEY,
and the rest are varchar(255) fields. - This is the OLDTABLE
I have created a new table, and repeated the table I just described
over and over into this new table, there are now more than 3.6 million
records. - This is the new NEWTABLE
When I run a select like "select * from NEWTABLE where
auto_number="BLAHBLAH" it returns the record in miliseconds.
But when I query the integer(12) field "SELECT dnjNo FROM NEWTABLE
where dnjNo='$dnjno' limit 25", it takes 2 and half minutes to tell me
if the record does not exist, but only if does not exist, if it
exists, then the 25 rows are returned in about 3 seconds and then in
0.2 seconds for subsequent search.
Why does it take so long to tell me if a record does not exist?
Any suggestions on how I can improve this performance, since without
this how can I basically search for non-existant rows? Did I forget to
say that the CPU is running at full during the 2 and half minute.
Please help!
ghasem


A while ago I posted the message above. The problem was that the
fields which are defined as KEY could not be searched at fast as a KEY
should really be searched. Now I have resolved the problem which was
actually my mistake and the the field which was defined as key was not
atually being searched, but the select was being preformed on a
non-KEY field and that was the reason it was slow.
Now I decided to make all fields as KEY, there are also 6 varchar(255)
fields in the table which I have now defined them as FULLTEXT. But the
peformance is once again not fast enough. A select statement on the
integet field which is defined as KEY takes 0.01 second to tell if the
recod exists or not. A similar select statement with three
varchar(255) fields ANDed together takes much more time, close to 2
minutes. Is this normal behavious, or am I missing something.
ghasem
Jul 20 '05 #2
gh************@yahoo.com (ghasem) wrote in message news:<e9**************************@posting.google. com>...
Dear mySQL community,
I have once again turned to the user groups for a problem I cannot
solve myself! Atually, I have read all I can from the newsgroups on
this but I could not solve it myself.
Here it is:
mySQL server: version "4.0.20-standard" on localhost
hardware : 1.8 MHz Pentium 4 with 512 cache and 512 MB 266MHz RAM and
40 MB Matrox+ harddisk

Here is the problem:
There is a table which I has 7 fields, 3000 records. One field is
auto_number and is PRIMARY, second is an integer(12) field and is KEY,
and the rest are varchar(255) fields. - This is the OLDTABLE
I have created a new table, and repeated the table I just described
over and over into this new table, there are now more than 3.6 million
records. - This is the new NEWTABLE
When I run a select like "select * from NEWTABLE where
auto_number="BLAHBLAH" it returns the record in miliseconds.
But when I query the integer(12) field "SELECT dnjNo FROM NEWTABLE
where dnjNo='$dnjno' limit 25", it takes 2 and half minutes to tell me
if the record does not exist, but only if does not exist, if it
exists, then the 25 rows are returned in about 3 seconds and then in
0.2 seconds for subsequent search.
Why does it take so long to tell me if a record does not exist?
Any suggestions on how I can improve this performance, since without
this how can I basically search for non-existant rows? Did I forget to
say that the CPU is running at full during the 2 and half minute.
Please help!
ghasem


A while ago I posted the message above. The problem was that the
fields which are defined as KEY could not be searched at fast as a KEY
should really be searched. Now I have resolved the problem which was
actually my mistake and the the field which was defined as key was not
atually being searched, but the select was being preformed on a
non-KEY field and that was the reason it was slow.
Now I decided to make all fields as KEY, there are also 6 varchar(255)
fields in the table which I have now defined them as FULLTEXT. But the
peformance is once again not fast enough. A select statement on the
integet field which is defined as KEY takes 0.01 second to tell if the
recod exists or not. A similar select statement with three
varchar(255) fields ANDed together takes much more time, close to 2
minutes. Is this normal behavious, or am I missing something.
ghasem
Jul 20 '05 #3

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

Similar topics

0
by: Eric B. | last post by:
Hi, I'm somewhat new to MySql. I've been using it for a while, but pretty much out of the box setup, and am starting to suffer heavily with my larger tables. I have a table with 5,000,000+...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
11
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
9
by: elyob | last post by:
Hi, I'm looking at storing snippets of details in MySQL about what credit cards a business excepts. Rather than have a whole column for Visa, another for Amex etc ... I am looking at having a...
0
by: taras.di | last post by:
I'm trying to understand why MySQL isn't using all parts of the primary key when I add in an OR statement in the query. I have a people database, and a distances database. The people database...
8
by: Daz | last post by:
Hi everyone. I was faced with the choice of whether my problem is indeed a PHP problem or a MySQL. I have decided it's a PHP problem as I don't experience the same problem when I execute the...
1
by: paulq182 | last post by:
PLEASE HELP ME WITH MY CODE?? import java.sql.*; import java.io.*; class min_filmdb_rel_mysql { public static void main (String args ) throws SQLException, IOException {
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.