|
I have the following code:
SELECT <column>, count(*) FROM <table> GROUP BY <column> HAVING COUNT(*) > 1;
Is there any difference to the results or performance if I replace the COUNT(*) with COUNT('x')?
(This question is related to...
Started by Andrew on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Select count(*) from table
I'm not sure question, it was asked what....
The-difference-between-countcolumn-and-count
The major performance difference is that COUNT(*) can will return immediately, without needing to examine any rows.
|
|
I have the following query:
select column_name, count(column_name) from table group by column_name having count(column_name) > 1;
What would be the difference if I replaced all calls to count(column_name) to count(*) ?
This question was inspired by...
Started by Bill the Lizard on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
count(*) counts NULLs and count(column) does not
[edit] added this code so that people can run) insert #bla values(null,null) select count(*),count(id),count(id2) from #bla
results 7 3 2
To clarify SQLMenace'....
|
|
Count up and count down seems no difference, we can implement either one as we like. But actually what is the advantage for using count up and count down. what is the difference between them (besides that one is increment, another one is decrement)?
Started by Molly on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If you don't know where the end is, then count-up....
On the other hand, count up also works perfectly well, with the current count telling you how much you've done.
The current count tells you how many there are left to do.
|
Ask your Facebook Friends
|
Is there a difference between the following queries, assuming there is a primary field 'id' in the table (as in speed, etc)?
SELECT COUNT(id) FROM table
vs.
SELECT COUNT(*) FROM table
Started by James Simpson on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Have a look at Count(*) vs ....
But in for example PostgreSQL the COUNT(pkcolumnname) is much faster.
Not in MySQL, no, it has optimized the COUNT well (assuming that your id field is already a PK --which is fairly self-describing).
|
|
Most recent counts...
June Count 2010
That '70s Show (4130 | 137.67)
Ranked #48 out of 207
July Count 2010
That '70s Show (9141 | 294.87)
Ranked #26 out of 210
August Count 2010
That '70s Show (2378 | 76.71)
Ranked #83 out of 213
September Count 2010
...
Started by jackiehydelover on
, 15 posts
by 4 people.
Answer Snippets (Read the full thread at fanforum):
No more post-count no subtitle! Yes, let's move our shenanigans....
Ok d'ok.
Thanks guys and gals Aye, captain! Sorry about that.
As much as I appreciate the 30+ plus posts in the last post count thread, please put all OT topics threads all turn OT.
|
|
I thought LINQ to SQL was tuned for performance?
The following LINQ to SQL for counting is very poor
Dim uniqueFactors As Integer = db.LargeTable.Distinct.Count
produces:
SELECT COUNT(*) AS [value] FROM [dbo].[LargeTable] AS [t0] WHERE ([t0].[ID] % @p...
Started by Coppermill on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Since....
Selecting a rows from sysindexes (or preferably normal TSQL that perfoms ok.. .
The SELECT COUNT(*) is the only way SQL Server (and therefore LINQ) can give you an exact, up-to-date count of the rows in the table.
For larger tables.
|
|
CREATE TABLE `names` ( `name` varchar(20) );
Assume the "names" table contains all 40 million first names of everyone living in California (for example).
SELECT count(*) as count, name FROM names GROUP BY name ORDER BY name;
How can I optimize this query...
Started by ryan on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Do you actually have a bottleneck....
Well, what makes you think it's not already optimised? This looks like the sort of query a good database engine should be able to handle relatively easily - particularly if you've got an appropriate index on your table .
|
|
If I keep calling len() on a very long list, am I wasting time, or does it keep an int count in the background?
Started by PKKid on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Worry: Of course it saves the count and thus len() on lists is a pretty cheap operation.
|
|
In other words, how does the implementation keeps track of the count?
Is there a map-like object maintained which is accessible by all the shared_ptr instances whose key is the pointer's address and value is the number of references? If I've to implement...
Started by vito on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Each smart pointer object contains a shared reference count - one to the actual object and a pointer....
When you make copy of shared_ptr object it copy pointer with count of references, increase than one object at a time.
counting.
|
|
I'm trying to access the Count Property on the array of rows returned by the datatables select method, this is after converting the Web Project to 3.5
Started by keyoke on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
I was missing <add namespace="System.Linq"/> from my web.config.
Use .Length instead.
|