No, by multiple queries I mean that I have to querie for every title. The
query is:
Select if(Year<>'"+y+"','1','0') as quest,MM,Archive,record_num from inv where
((REPLACE(Title,'#','')='"+t+"' or REPLACE(Title,'#','')='"+s+"' or
REPLACE(Title,'#','')='"+u+"' or REPLACE(Title,'#','')='"+v+"' or
REPLACE(Title,'#','')='"+w+"') or Mtitle='"+mu+"' or Mtitle='"+mu2+"') and
((Year>'"+(((int)y)-3)+"' AND Year<'"+(((int)y)+3)+"') or
Year='')"+(id->variables->pi=="1"?" AND MM='PAPR' ":"")+" ORDER BY Archive,MM

This is from the code and the variables such as y (+y+) are replaced as it
loops through. What I have to do with the results of this is to parse through
and count the MM and Archive differences. Needless to say, this code is just
inefficient and the reason why I know there has to be a better way. I have
played with some other code that uses a querie with a count but I ran into
some snags with that as well.

Kevin Pratt wrote:

> Hello
>     Are you querying once for each field?  Can you put up a sample of the
> query that you are doing?
>     If you are querying for each filed to build your result you should
> compact the query in to one i.e.
>     if you are doing
>     select  MM from table1 where record_num = 3
>     select  Title from table1 where record_num = 3
>     select  Archive from table1 where record_num = 3
>     then you should replace these lines with something like
>     select MM,Title,Archive from table1 where record_num = 3
>     this will return faster than doing each query separately
> Kevin
> ----- Original Message -----
> From: "Carl Schrader" <[EMAIL PROTECTED]>
> To: "Mysql" <[EMAIL PROTECTED]>
> Sent: Wednesday, May 16, 2001 9:08 AM
> Subject: Speed question
>
> > I am searching to speed up an operation I have, which works - it just
> > takes minutes to finish. The current script is written in pike (a C like
> > scripting language). I believe that most of the overhead is the multiple
> > queries. Would using C++ be significantly faster? (I'd have to learn
> > some C before I could do this, so, the speed increase needs to be worth
> > the effort).
> >
> > Let me explain the situation:
> >
> > Table 1 is defined as:
> > MM;varchar(4)
> > Title;varchar(48)
> > Archive;varchar(4)
> > record_num;int(8) unsigned zerofill
> >
> > I am given a list of Titles. With these Title's I need to search Table 1
> > for the Title and output as follows:
> >
> > Green Mile 10 35mm TRLR  6 16mm BCAM
> > Cast Away 4 35mm 20 BETA
> >
> > In the above example, Green Mile=Title 35mm=MM TRLR=Archive etc. So we
> > have 10 35mm TRLR of Green Mile.
> > Currently I am querying several times to get the result. This is slow
> > because the list could be 50 Titles.
> >
> > Thanks for any advance you can give on this.
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> >


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to