473,386 Members | 1,693 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,386 software developers and data experts.

Question regarding indexing and table structure practices

Im at my wit's end!

Im using mysql 4.0.23 (win32)

Show create:
CREATE TABLE `dbcurrent` (
`Filespec` varchar(254) NOT NULL default '',
`ID` int(11) unsigned NOT NULL auto_increment,
`InUse` int(11) default NULL,
PRIMARY KEY (`Filespec`),
UNIQUE KEY `IDX_ID` (`ID`),
UNIQUE KEY `IDX_INUSE` (`InUse`,`Filespec`,`ID`)
) TYPE=MyISAM MAX_ROWS=100000000;

Query :
Select Filespec from dbCurrent where inUse is null order by id desc limit 1

Database size : 6,406,347

Is there a better way to index this table so the Query doesnt take forever
(this query takes about 30-45 seconds to execute) or a better way to word my
query???
Essentially I want the newest record in dbCurrent (by natural ID) thats not
marked InUse=1....
Jul 20 '05 #1
1 1154
Craig Stadler wrote:
Query :
Select Filespec from dbCurrent where inUse is null order by id desc limit 1


Given MySQL 4.0.x, I would do this in two queries:

SELECT MIN(id) FROM dbCurrent WHERE inUse IS NULL

Save the result, and use it as a parameter to the second query:

SELECT Filespec FROM dbCurrent WHERE id = ?

Regards,
Bill K.
Jul 20 '05 #2

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

Similar topics

8
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a...
5
by: lixiaoyao | last post by:
hi all I use matrix & vector function to allocate the space myself in c, typedef struct matrix_array newdata; struct matrix_array{ float **sy,*sxx; }; newdata ndata;//new data struct...
55
by: Steve Jorgensen | last post by:
In a recent thread, RKC (correctly, I believe), took issue with my use of multiple parameters in a Property Let procedure to pass dimensional arguments on the basis that, although it works, it's...
9
by: noone | last post by:
I have a database file that I use an autonumber field as the primary key index. Because of some rearrangements in the past, this index does not match the order that I would like it to be in, that...
6
by: rodchar | last post by:
Hey all, I'm trying to understand Master/Detail concepts in VB.NET. If I do a data adapter fill for both customer and orders from Northwind where should that dataset live? What client is...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
2
by: Terrance | last post by:
Hello, I have a question in regards to hashtables that I was hoping someone can share some light on. I'm currently working with VB.net and I'm trying to learn as much as possible about the...
7
by: Ryan | last post by:
I have a bit of a problem with regards an indexing strategy. Well, basically there is no indexing strategy on a set of data I have at work. Now, I didn't create the design as I would have allowed...
12
by: nyathancha | last post by:
Hi, I have a question regarding best practices in database design. In a relational database, is it wise/necessary to sometimes create tables that are not related to other tables through a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.