getCount() not DISTINCT()?
See original GitHub issueIssue type:
[ ] question [ ] bug report [x ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[x ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
now getCount() => select count(DISTINCT(id)), i want select count(id)or
select count(*)
.getCount({ DISTINCT: false })
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Get COUNT() AND COUNT(DISTINCT()) values across 2 tables
It's a query in the FROM clause , and you're referencing the resultset from a query like it was a table. (The MySQL...
Read more >Count unique values among duplicates - Microsoft Support
Let's say you want to find out how many unique values exist in a range that contains duplicate values. For example, if a...
Read more >Counting Rows That Satisfy a Condition - PostgreSQL Tutorial
In this form, the COUNT(DISTINCT column) returns the number of unique non-null values in the column. ... We often use the COUNT() function...
Read more >Aggregation, grouping, and summarizing (Concepts) - Prisma
Use Prisma Client to aggregate, group by, count, and select distinct. ... This excludes count , which always returns 0 if no records...
Read more >How to count unique values in Excel an easy way - Ablebits
If you have not used any of these functions yet, ... Count unique values in column; Get count of unique values that occur...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Id is primary key. My problem is when the amount of data is too large, the query speed is not as good
@imnotjames I was thinking of creating a new issue here for a Feature Request, since I’d like the
repository.count()
to have the possibility to be not distinct. But then I found this issue and read your comments, and now I’m not so sure.This feature is wanted by me due to the fact that in Postgres, a
COUNT(DISTINCT...))
query can be pretty heavy. There are quite a few references online talking about that, this article being one example. So, for Postgres, it’d be great if we could tell typeorm that we know that the distinct is not needed. The default behaviour would keep being the current one, of course.Do you think this feature would be useful? I’m currently getting around it by using a QueryBuilder, but it’d be far less verbose if I could just pass an option to
count
.