Pls confirm which of the two ways is more efficient or more recommended-
please advise if it even makes a difference. Thanks!
SELECT count(fieldname) as thecount
OR
SELECT fieldname
..
..
cfset countfromquery = queryname.recordcount
Pls confirm which of the two ways is more efficient or more
recommended- please advise if it even makes a difference. Thanks!
SELECT count(fieldname) as thecount
OR
SELECT fieldname
..
..
cfset countfromquery = queryname.recordcount
If you don't need the actual records, COUNT.
Count(primaryKey) is definitely better. Less information returned from
the database so less bandwidth is used, plus the result can be
obtained instantly from the index (I suppose this depends on the db).
-Mike Chabot
On 9/6/06, Michael E. Carluen [EMAIL PROTECTED] wrote:
Pls confirm which of
one returns a single integer with the count.
the other returns every single fieldname in the table
I would think the first would always be quicker.
On the other hand, if you need the list of fields anyway, option 2
comes free with the query.
On 9/6/06, Michael E. Carluen [EMAIL PROTECTED]
Thanks Dave W., Mike!
-Original Message-
From: Mike Chabot [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 06, 2006 3:35 PM
To: CF-Talk
Subject: Re: COUNT() versus .recordcount
Count(primaryKey) is definitely better. Less information returned from
the database so less
Ok, Justin MacCarthy pointed out something for me to try. He suggested
using count(cfid) instead of count(*) which would yield the same results.
This table has like 944 records btw, here are the results of time in ms
taken to run 1000 queries of each over 5 tries:
Using count(cfid): 3313
Well, that is kind of a weighted test then, since using Count() + data
verses RecordCount + data, you are really just adding Count(), since the
data and RecordCount is given with both of those.
Justin Kidman
-Original Message-
From: Kevin Miller [mailto:[EMAIL PROTECTED]]
Sent
: count() or recordcount
In my situation, I needed the data anyway, so the comparison was
Count() + data versus RecordCount + data.
Kevin
[EMAIL PROTECTED] 09/06/00 01:01PM
I tested this using CF 4.01 using a 9000+ record Access database.
Using Query.RecordCount was actually about 10-20
Which is faster? I'm presuming count() or what else would it be good for?
--
Bud Schneehagen - Tropical Web Creations
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452
--
Andrew Ewings
Project Manager
Thoughtbubble Ltd
--
-Original Message-
From: Bud [mailto:[EMAIL PROTECTED]]
Sent: 06 September 2000 17:12
To: [EMAIL PROTECTED]
Subject: count() or recordcount
Which is faster? I'm presuming
, September 06, 2000 9:12 AM
To: [EMAIL PROTECTED]
Subject: count() or recordcount
Which is faster? I'm presuming count() or what else would it be good for?
--
Bud Schneehagen - Tropical Web Creations
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED
Just ran a test using my CGLOBAL table that holds client variables in an
ODBC database. Over 1000 loops of a query grabbing cfid and using
recordcount, it took 20031 ms of time. To get the recordcount using the
count(*) method, over 1000 loops of the same table, it only took 3406 ms.
So, if you
In a direct comparison, I would think count() would be since it's run on the
SQL server.
Todd Ashworth
- Original Message -
From: "Bud" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 06, 2000 12:11 PM
Subject: count() or recordcount
| Which is faster? I'm
-Original Message-
From: Andy Ewings [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 06, 2000 9:17 AM
To: '[EMAIL PROTECTED]'
Subject: RE: count() or recordcount
If you do a select * and then do a record count you have to perform 2
operations. Select count(*) is only one so I think you
Message-
From: Bud [mailto:[EMAIL PROTECTED]]
Sent: 06 September 2000 17:12
To: [EMAIL PROTECTED]
Subject: count() or recordcount
Which is faster? I'm presuming count() or what else would it be good
for?
--
Bud Schneehagen - Tropical Web Creations
Kidman
-Original Message-
From: Justin Kidman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 06, 2000 9:24 AM
To: '[EMAIL PROTECTED]'
Subject: RE: count() or recordcount
Just ran a test using my CGLOBAL table that holds client variables in an
ODBC database. Over 1000 loops
PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: Wednesday, September 06, 2000 12:31 PM
Subject: Re: count() or recordcount
In a direct comparison, I would think count() would be since it's run on
the
SQL server.
Todd Ashworth
- Original Message -
From: "Bud" [EMAIL
---[ ]---
-Original Message-
From: Jamie Keane [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 06, 2000 1:08 PM
To: [EMAIL PROTECTED]
Subject: Re: count() or recordcount
Furthermore, count() is just that, a tally of the rows as a query column in
and of itself. The RecordCount variable
If you do a select * and then do a record count you have to
perform 2 operations. Select count(*) is only one so I think
you are right - count(*) will be faster but it'll be negligible
unless you have a huge amount of records
Actually, the difference can be pretty significant even with
On 9/6/00, Dan Haley penned:
Two totally different beasts. If you want to pull data back from the
database and then determine how many rows were returned, use
query.recordcount rather than going back to the database for a row count.
If you only want to find out how many rows but don't need the
le
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"
HTML
HEAD
META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1"
META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2650.12"
TITLERE: count() or recordcount/T
al Message-
From: Kuehn, Matthew [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 06, 2000 17:58
To: '[EMAIL PROTECTED]'
Subject: RE: count() or recordcount
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not
le
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"
HTML
HEAD
META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1"
META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2650.12"
TITLERE: count() or recordcount/T
In my situation, I needed the data anyway, so the comparison was
Count() + data versus RecordCount + data.
Kevin
[EMAIL PROTECTED] 09/06/00 01:01PM
I tested this using CF 4.01 using a 9000+ record Access database.
Using Query.RecordCount was actually about 10-20% faster.
The thing
24 matches
Mail list logo