Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Liczenie rekordów
acztery
post
Post #1





Grupa: Zarejestrowani
Postów: 945
Pomógł: 7
Dołączył: 15.03.2005
Skąd: katowice

Ostrzeżenie: (0%)
-----


witam,

mam tabele z 220 tys rekordów

i chce policzyc wszystkie ktore spelniaja jakis warunek ale to tra bardzo dlugo. ok 30 sek.

  1. SELECT Count(id)
  2. FROM prg
  3. WHERE UserID='Ux1'


czy mysql ma jakies wbudowane funkcje np count_big tak jak w sql server 2000

Ten post edytował acztery 15.03.2006, 00:18:26
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
DeyV
post
Post #2





Grupa: Zarząd
Postów: 2 277
Pomógł: 6
Dołączył: 27.12.2002
Skąd: Wołów/Wrocław




Manual MySQL podpowiada


Cytat
If you very often need to calculate results such as counts based on information from a lot of rows, it's probably much better to introduce a new table and update the counter in real time. An update of the following form is very fast:
  1. UPDATE tbl_name SET count_col=count_col+1 WHERE key_col=constant;


This is really important when you use MySQL storage engines such as MyISAM and ISAM that have only table-level locking (multiple readers / single writers). This will also give better performance with most databases, because the row locking manager in this case will have less to do.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 17:48