Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > Database
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 9:34 PM   #1
StockN@gmail.com
 
StockN@gmail.com's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Mysql infinite loop?!

this query doesnt work:
SELECT d.cID,d.cLName,d.cFName , k.kid
FROM cname d, cu_key e, rep_key f , `key` k
WHERE (d.cLName LIKE '%') and (((e.cID = d.cID) and
(k.kID=e.keyID))or((f.repID = d.cID)
and (k.kID=f.keyID))) and
( (k.UserSupportExp >= '2001-01-01' ) and (k.UserSupportExp
<='2002-01-01') )
order by d.cLName,d.cFName LIMIT 0, 50

if i take out either of the statments connected by the or clause, the
query works, otherwise it times out after 3000 seconds.

SELECT d.cID,d.cLName,d.cFName , k.kid
FROM cname d, cu_key e, rep_key f , `key` k
WHERE (d.cLName LIKE '%') and (((e.cID = d.cID) and (k.kID=e.keyID)))
and
( (k.UserSupportExp >= '2001-01-01' ) and (k.UserSupportExp
<='2002-01-01') )
order by d.cLName,d.cFName LIMIT 0, 50

any ideals?
thanks in advance nick

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 9:34 PM   #2
Bill Karwin
 
Bill Karwin's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Mysql infinite loop?!

StockN@gmail.com wrote:
> SELECT d.cID,d.cLName,d.cFName , k.kid
> FROM cname d, cu_key e, rep_key f , `key` k
> WHERE (d.cLName LIKE '%') and (((e.cID = d.cID) and
> (k.kID=e.keyID))or((f.repID = d.cID)
> and (k.kID=f.keyID))) and
> ( (k.UserSupportExp >= '2001-01-01' ) and (k.UserSupportExp
> <='2002-01-01') )
> order by d.cLName,d.cFName LIMIT 0, 50
>
> if i take out either of the statments connected by the or clause, the
> query works, otherwise it times out after 3000 seconds.


So it takes a long time, but this doesn't mean it's an infinite loop.
It just means your query is very expensive and takes too long.

What is the purpose of using "LIKE '%'"? This use of the wildcard
matches all rows, but ensures no index can be used, so it forces a
table-scan on your cname table. This can be costly, and probably causes
the query to take a long time, thus you're getting a timeout.

This might not be the only performance problem. What indexes do you
have in these tables? Have you used EXPLAIN to analyze the query, so
you know what additional indexes you should create?

You also have a non-normalized relationship between your tables: k.kID
and d.cID can reference either of two tables (cu_key or rep_key). I
predict that this design will become harder and harder to manage, until
it becomes completely broken. You should combine the cu_key and rep_key
tables into one table, so you can have a cleaner reference relationship
between your tables.

Regards,
Bill K.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
redo the nth loop SpamBait PHP 1 07-01-2007 5:25 PM
call a PHP script from a while loop over & over pprince PHP 1 07-01-2007 3:49 PM
using for loop with str_replace & $_files array Eric Haskins PHP 2 07-01-2007 3:35 PM
Loop Emulation...is it possible? Abraxas Software Programming 0 06-12-2007 11:28 PM
Infinite Level MLM - and it's International!! Sweetpuppy Building An Internet Business 0 05-29-2007 2:36 AM


Featured Websites




All times are GMT +1. The time now is 6:29 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98