FAQ
Hi there,

How can I get row count information from DBI?
Thanks in advance

David

Search Discussions

  • Tim Bunce at Jan 31, 2002 at 11:29 pm

    On Thu, Jan 31, 2002 at 04:44:45PM -0500, Zhao, David [PRDUS Non J&J] wrote:
    Hi there,

    How can I get row count information from DBI?
    Doesn't the fine manual tell you?

    Tim.
  • Michael A Chase at Jan 31, 2002 at 11:30 pm
    Count the rows as you process them. There is a $sth->rows method, but read
    the fine manual (perldoc DBI) to see why it isn't a good idea to depend on
    it for SELECT.

    --
    Mac :})
    ** I normally forward private questions to the appropriate mail list. **
    Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.htm
    Give a hobbit a fish and he eats fish for a day.
    Give a hobbit a ring and he eats fish for an age.
    ----- Original Message -----
    From: "Zhao, David [PRDUS Non J&J]" <DZhao1@PRDUS.JNJ.COM>
    To: <dbi-users@perl.org>
    Sent: Thursday, January 31, 2002 13:44
    Subject: how to get row count using DBI

    How can I get row count information from DBI?
  • Moritz von Schweinitz at Jan 31, 2002 at 11:44 pm
    i would of course never dare to doubt the fine-ness of the manual, and
    am pressing for a nobel prize for literature for it, BUT:

    is there really no resource-friendly, fast&simple way to find out how
    many rows a query could return, without weeding thru all the rows - i
    somehow doubt that websites that claim "we have 1.234.678 [whatever]
    registered in our database" run thru their whole database every time. my
    is that they store the number of entries every time they do an "INSERT",
    but still...

    (i'm using mysql v3.23, but i think this is a more general
    db-engineering problem)

    M.
    -----Original Message-----
    From: Michael A Chase
    Sent: Thursday, January 31, 2002 5:23 PM
    To: Zhao, David [PRDUS Non J&J]; dbi-users@perl.org
    Subject: Re: how to get row count using DBI


    Count the rows as you process them. There is a $sth->rows
    method, but read the fine manual (perldoc DBI) to see why it
    isn't a good idea to depend on it for SELECT.

    --
    Mac :})
    ** I normally forward private questions to the appropriate
    mail list. ** Ask Smarter:
    http://www.tuxedo.org/~esr/faqs/smart-> questions.htm
    Give a
    hobbit a fish and he eats fish for a
    day.
    Give a hobbit a ring and he eats fish for an age.
    ----- Original Message -----
    From: "Zhao, David [PRDUS Non J&J]" <DZhao1@PRDUS.JNJ.COM>
    To: <dbi-users@perl.org>
    Sent: Thursday, January 31, 2002 13:44
    Subject: how to get row count using DBI

    How can I get row count information from DBI?
  • Michael Peppler at Jan 31, 2002 at 11:49 pm
    They probably do a
    select count(*) from ... where ...
    to get that information.

    Michael

    Moritz von Schweinitz writes:
    i would of course never dare to doubt the fine-ness of the manual, and
    am pressing for a nobel prize for literature for it, BUT: >
    is there really no resource-friendly, fast&simple way to find out how
    many rows a query could return, without weeding thru all the rows - i
    somehow doubt that websites that claim "we have 1.234.678 [whatever]
    registered in our database" run thru their whole database every time. my
    is that they store the number of entries every time they do an "INSERT",
    but still... >
    (i'm using mysql v3.23, but i think this is a more general
    db-engineering problem) >
    M.
    >
    -----Original Message-----
    From: Michael A Chase
    Sent: Thursday, January 31, 2002 5:23 PM
    To: Zhao, David [PRDUS Non J&J]; dbi-users@perl.org
    Subject: Re: how to get row count using DBI
    > >
    > >
    Count the rows as you process them. There is a $sth->rows
    method, but read the fine manual (perldoc DBI) to see why it
    isn't a good idea to depend on it for SELECT.
    > >
    --
    Mac :})
    ** I normally forward private questions to the appropriate
    mail list. ** Ask Smarter:
    http://www.tuxedo.org/~esr/faqs/smart-> questions.htm
    Give a
    hobbit a fish and he eats fish for a
    day.
    Give a hobbit a ring and he eats fish for an age.
    ----- Original Message -----
    From: "Zhao, David [PRDUS Non J&J]" <DZhao1@PRDUS.JNJ.COM>
    To: <dbi-users@perl.org>
    Sent: Thursday, January 31, 2002 13:44
    Subject: how to get row count using DBI
    > >
    > >
    How can I get row count information from DBI?
    > >
    > >
    > >
    >

    --
    Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
    mpeppler@peppler.org - mpeppler@mbay.net
    International Sybase User Group - http://www.isug.com
  • Tim Bunce at Feb 1, 2002 at 12:16 am

    On Thu, Jan 31, 2002 at 03:49:29PM -0800, Michael Peppler wrote:
    They probably do a
    select count(*) from ... where ...
    to get that information.
    And then cache it.

    Tim.
    Michael

    Moritz von Schweinitz writes:
    i would of course never dare to doubt the fine-ness of the manual, and
    am pressing for a nobel prize for literature for it, BUT:

    is there really no resource-friendly, fast&simple way to find out how
    many rows a query could return, without weeding thru all the rows - i
    somehow doubt that websites that claim "we have 1.234.678 [whatever]
    registered in our database" run thru their whole database every time. my
    is that they store the number of entries every time they do an "INSERT",
    but still...

    (i'm using mysql v3.23, but i think this is a more general
    db-engineering problem)

    M.
    -----Original Message-----
    From: Michael A Chase
    Sent: Thursday, January 31, 2002 5:23 PM
    To: Zhao, David [PRDUS Non J&J]; dbi-users@perl.org
    Subject: Re: how to get row count using DBI


    Count the rows as you process them. There is a $sth->rows
    method, but read the fine manual (perldoc DBI) to see why it
    isn't a good idea to depend on it for SELECT.

    --
    Mac :})
    ** I normally forward private questions to the appropriate
    mail list. ** Ask Smarter:
    http://www.tuxedo.org/~esr/faqs/smart-> questions.htm
    Give a
    hobbit a fish and he eats fish for a
    day.
    Give a hobbit a ring and he eats fish for an age.
    ----- Original Message -----
    From: "Zhao, David [PRDUS Non J&J]" <DZhao1@PRDUS.JNJ.COM>
    To: <dbi-users@perl.org>
    Sent: Thursday, January 31, 2002 13:44
    Subject: how to get row count using DBI

    How can I get row count information from DBI?
    --
    Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
    mpeppler@peppler.org - mpeppler@mbay.net
    International Sybase User Group - http://www.isug.com
  • Cfm at Feb 1, 2002 at 2:05 am

    On Fri, Feb 01, 2002 at 12:15:41AM +0000, Tim Bunce wrote:
    On Thu, Jan 31, 2002 at 03:49:29PM -0800, Michael Peppler wrote:
    They probably do a
    select count(*) from ... where ...
    to get that information.
    And then cache it.
    ....
    is there really no resource-friendly, fast&simple way to find out how
    many rows a query could return, without weeding thru all the rows - i
    somehow doubt that websites that claim "we have 1.234.678 [whatever]
    registered in our database" run thru their whole database every time. my
    is that they store the number of entries every time they do an "INSERT",
    but still...
    Make sure that your setup does in fact support that method. Speaking
    from very fresh, raw and painful experience, it seems that

    linux -> ODBC -> IBM iSeries driver -> AS/400

    does not.




    --

    Christopher F. Miller, Publisher cfm@maine.com
    MaineStreet Communications, Inc 208 Portland Road, Gray, ME 04039
    1.207.657.5078 http://www.maine.com/
    Content/site management, online commerce, internet integration, Debian linux
  • Kokarski, Anton at Jan 31, 2002 at 11:47 pm
    you can use select count(*) from table query

    Anton

    -----Original Message-----
    From: Moritz von Schweinitz
    Sent: Thursday, January 31, 2002 3:47 PM
    To: dbi-users@perl.org
    Subject: RE: how to get row count using DBI


    i would of course never dare to doubt the fine-ness of the manual, and
    am pressing for a nobel prize for literature for it, BUT:

    is there really no resource-friendly, fast&simple way to find out how
    many rows a query could return, without weeding thru all the rows - i
    somehow doubt that websites that claim "we have 1.234.678 [whatever]
    registered in our database" run thru their whole database every time. my
    is that they store the number of entries every time they do an "INSERT",
    but still...

    (i'm using mysql v3.23, but i think this is a more general
    db-engineering problem)

    M.
    -----Original Message-----
    From: Michael A Chase
    Sent: Thursday, January 31, 2002 5:23 PM
    To: Zhao, David [PRDUS Non J&J]; dbi-users@perl.org
    Subject: Re: how to get row count using DBI


    Count the rows as you process them. There is a $sth->rows
    method, but read the fine manual (perldoc DBI) to see why it
    isn't a good idea to depend on it for SELECT.

    --
    Mac :})
    ** I normally forward private questions to the appropriate
    mail list. ** Ask Smarter:
    http://www.tuxedo.org/~esr/faqs/smart-> questions.htm
    Give a
    hobbit a fish and he eats fish for a
    day.
    Give a hobbit a ring and he eats fish for an age.
    ----- Original Message -----
    From: "Zhao, David [PRDUS Non J&J]" <DZhao1@PRDUS.JNJ.COM>
    To: <dbi-users@perl.org>
    Sent: Thursday, January 31, 2002 13:44
    Subject: how to get row count using DBI

    How can I get row count information from DBI?
  • James.FitzGibbon at Jan 31, 2002 at 11:53 pm

    is there really no resource-friendly, fast&simple way to find out how
    many rows a query could return, without weeding thru all the rows - i
    somehow doubt that websites that claim "we have 1.234.678 [whatever]
    registered in our database" run thru their whole database
    every time. my
    is that they store the number of entries every time they do
    an "INSERT",
    but still...
    $rows = $dbh->selectrow_array("SELECT COUNT(foo) FROM bar");

    --
    j.

    James FitzGibbon voice/fax 612-761-6121/4277
    Consultant, TTS-3D@TPN4H james.fitzgibbon@target.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-users @
categoriesperl
postedJan 31, '02 at 10:08p
activeFeb 1, '02 at 2:05a
posts9
users8
websitedbi.perl.org

People

Translate

site design / logo © 2022 Grokbase