Re: Re: adodb execute method
Alejandro Michelin Salomon ( Adinet <alejmsg <at> adinet.com.uy>
2006-03-03 11:32:00 GMT
Hi Alfredo :
Try this :
SELECT COUNT(*)
FROM table1
Alejandro Michelin Salomon
Porto Alegre
Brasil
Message: 2
Date: Thu, 2 Mar 2006 07:28:32 -0500
From: "Alfredo Yong" <alfredoyong <at> gmail.com>
Reply-To: alfredo <at> alfredoyong.com
To: Darius <darius <at> m2t.lt>
Subject: Re: [ADodb-general] Re: adodb execute method
Cc: adodb-general <at> lists.sourceforge.net
------=_Part_5594_22239041.1141302512018
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hi Darious,
I use a code like this:
$SQL =3D "select * from table1";
$SQLCount =3D "select count(*) from ($SQL)";
Then I use $SQLCount to know the row count, and $SQL with a SelectLimit
But Im afraid the cost of this two queries is more than double the original
($SQL) query
Any better idea?
greetings,
On 3/2/06, Darius <darius <at> m2t.lt> wrote:
>
> Hi all,
>
> we have also the same problem.
> With selectLimit(..) I retrieve only needed rows. But there need to
> know count of all rows. In MySQL I can do this with
> SQL_CALC_FOUND_ROWS. What is solution in AdoD=
B
> ?
>
> Best regards,
> Darius
>
>
> Marcin Szkudlarek wrote:
>
> > Thanks for reply. You are right - I want to implement paging but
> > it"s not that simple. I want to select 100 rows from 50k table but I
> > don"t know how much rows I have to fetch to get the 100 .. it could
> > be in the WORST case the last 100 from the whole 50k table. I"t
> > because I"m checking access rights to every row in php and then
> > diplaying it or not. So your example with selecting only first 100
> > rows from the table woudn"t work here. If there isn"t a way to fetch
> > the result row by row I"ll have to reimplement some ugly code.
>
> > You have just described the classic poorly designed application.
> >
>
> >If there"s something in the data that you can look at and determind
> >access rights in PHP, then you should move that logic to your SQL
> >query and select only the rows you"re interested in.
>
> >
> > Best regards,
> >
> > Marcin Szkudlarek
> >
> > On Fri, 24 Jun 2005, Emil Zegers wrote:
> >
> >> What do you exactly mean by "fetching the rows"?
> >>
> >> If you want to do a row count then your query could be something
> >> like "SELECT COUNT(*) FROM TABLENAME"
> >>
> >> If you want to get only a certain amount of rows you can do
> >> something like "SELECT TOP 100 * FROM TABLENAME".
> >>
> >> Also take a look at paging options.
> >>
> >> If you do want to get the data in a recordset for manipulation you
> >> really have to fetch it.
> >>
> >> You can limit the data (and thus the query time) by selecting only
> >> the columns needed.
> >>
> >> Regards,
> >>
> >> Emil
> >>
> >> -----Original Message-----
> >> From: adodb-general-admin <at> li... [mailto:adodb-general-admin <at> li...]
> >> On Behalf Of Marcin Szkudlarek
> >> Sent: vrijdag 24 juni 2005 11:49
> >> To: adodb-general <at> li...
> >> Subject: [ADodb-general] adodb execute method
> >>
> >> Hi!
> >>
> >> I"m using ado 4.62 with oracle 8.17. My question:
> >> is there a way to execute select query without getting all the
> >> results=
?
> >> I have a table with about 50k records and calling only the execute
> >> method takes about 1,8s. What I want to achieve is fetching the
> >> rows without having to get all the data at once.
> >>
> >> Thanks.
> >>
> >> Marcin Szkudlarek
--
Alfredo Yong
Sistemas web
------=_Part_5594_22239041.1141302512018
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
<div>Hi Darious,</div>
<div> </div>
<div>I use a code like this:</div>
<div> </div>
<div>$SQL =3D "select * from table1";</div> <div>$SQLCount =3D
"select count(*) from ($SQL)";</div> <div> </div> <div>Then I
use $SQLCount to know the row count, and $SQL with a SelectLimi= t</div>
<div> </div> <div>But Im afraid the cost of this two queries is more
than double the ori= ginal ($SQL) query</div> <div> </div> <div>Any
better idea?</div> <div><br>greetings,<br> </div>
<div><span class=3D"gmail_quote">On 3/2/06, <b class=3D"gmail_sendername">D=
arius</b> <<a href=3D"mailto:darius <at> m2t.lt">darius <at> m2t.lt</a>> wrote:=
</span> <blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex;
MARGIN: 0px 0= px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi all,<br><br>we
have also the = same problem.<br>With selectLimit(..) I retrieve only needed
rows. But ther= e need to know count of all rows. <br>In MySQL I can do this
with SQL_CALC_FOUND_ROWS. What is solution in Ad= oDB ?<br><br>Best
regards,<br>Darius<br><br><br>Marcin Szkudlarek wrote:<br=
><br>> Thanks for reply. You are right - I want to implement paging
>but =
it"s
<br>> not that simple. I want to select 100 rows from 50k table but I do=
n"t<br>> know how much rows I have to fetch to get the 100 .. it co=
uld be in<br>> the WORST case the last 100 from the whole 50k table. I&q=
uot;t because I"m <br>> checking access rights to every row in php
and then diplaying it o= r<br>> not. So your example with selecting only
first 100 rows from the = table<br>> woudn"t work here. If there
isn"t a way to fetch th= e result row by row <br>> I"ll have to
reimplement some ugly code.<br><br>> You have= just described the
classic poorly designed application.
<br>= <br>>If
there"s something in the data that you can look at and dete= rmind<br>
>access rights in PHP, then you should move that logic to your SQL query=
<br>>and select only the rows you"re interested in.<br><br>><br>=
> Best regards,<br>><br>> Marcin Szkudlarek<br>><br>> On Fri=
, 24 Jun 2005, Emil Zegers wrote: <br>><br>>> What do you exactly
mean by "fetching the rows&qu= ot;?<br>>><br>>> If you want
to do a row count then your query = could be something like<br>>>
"SELECT COUNT(*) FROM TABLENAME&qu= ot; <br>>><br>>> If you
want to get only a certain amount of rows y= ou can do something<br>>>
like "SELECT TOP 100 * FROM TABLENAME&= quot;.<br>>><br>>>
Also take a look at paging options.<br>>&= gt; <br>>> If you do
want to get the data in a recordset for manipulation= you<br>>>
really have to fetch it.<br>>><br>>> You can l= imit the data
(and thus the query time) by selecting only the<br>>> c= olumns
needed. <br>>><br>>> Regards,<br>>><br>>>
Emil<br>>><=
br>>> -----Original Message-----<br>>> From:
br>adodb-general-admi=
n <at> li...<br>>> [mailto:<a href=3D"mailto:adodb-general-admin <at> li">adodb=
-general-admin <at> li
</a>...] On Behalf Of Marcin<br>>> Szkudlarek<br>>> Sent: vrijd=
ag 24 juni 2005 11:49<br>>> To: adodb-general <at> li...<br>>> Subje=
ct: [ADodb-general] adodb execute method<br>>><br>>> Hi!<br>
>><br>>> I"m using ado 4.62 with oracle 8.17. My question:=
<br>>> is there a way to execute select query without getting all the=
results?<br>>> I have a table with about 50k records and calling onl=
y the execute <br>>> method takes about 1,8s. What I want to achieve
is fetching th= e rows<br>>> without having to get all the data at
once.<br>>><=
br>>> Thanks.<br>>><br>>> Marcin
br>Szkudlarek</blockquote>
</div><br><br clear=3D"all"><br>-- <br>Alfredo Yong<br>Sistemas web=20
------=_Part_5594_22239041.1141302512018--
--__--__--
_______________________________________________
ADodb-general mailing list
ADodb-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/adodb-general
End of ADodb-general Digest
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.1/273 - Release Date: 2/3/2006
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.1/273 - Release Date: 2/3/2006
--
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.1/273 - Release Date: 2/3/2006
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642