Chúng tôi không thể tìm thấy kết nối internet
Đang cố gắng kết nối lại
Có lỗi xảy ra!
Hãy kiên nhẫn trong khi chúng tôi khắc phục sự cố
Cách tốt nhất để đếm tổng số hàng trong một bảng: COUNT(*) so với COUNT(1)
If you need to count the total number of rows in a relational table, the COUNT() function often comes to mind first. However, if you search online, you'll come across many resources suggesting that COUNT(1) is more efficient. So, should we use COUNT(), COUNT(1), or even COUNT(id)?
In this video, you'll learn which version of the COUNT function is the most efficient by reviewing how the function works, comparing execution plans, and analyzing latencies across four major databases: PostgreSQL, Oracle, MySQL, and SQL Server.
0:00 COUNT(*) vs. COUNT(1) dilemma
0:40 PostgreSQL, comparing execution plans
4:30 PostgreSQL, comparing latencies
5:32 Oracle, comparing execution plans
7:30 Oracle, comparing latencies
8:25 MySQL, comparing execution plans
9:20 MySQL, comparing latencies
10:50 SQL Server, comparing execution plans
12:52 SQL Server, comparing latencies
13:17 When does an index make things faster?
Curios to learn even more about databases, follow me here:
* Medium: https://medium.com/@magda7817
* X (Twitter): https://twitter.com/denismagda
Dịch Vào Lúc: 2025-06-29T14:40:38Z