speed up distinct selection....

User avatar
sal21
PlatinumLounger
Posts: 4364
Joined: 26 Apr 2010, 17:36

speed up distinct selection....

Post by sal21 »

SQL = "SELECT DISTINCT ANNO FROM VIAGGIANTI_PTF ORDER BY ANNO"

i use thsi to selct distinct drom field ANNo but is very slow with 560.xxx records in fileds hereis other way(?!) :groan: :scratch: :sad:
VBA code for Excel...

User avatar
HansV
Administrator
Posts: 78575
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: speed up distinct selection....

Post by HansV »

Do you have an index on the ANNO field? That should help.

Try either

SQL = "SELECT DISTINCT ANNO FROM VIAGGIANTI_PTF"

or

SQL = "SELECT ANNO FROM VIAGGIANTI_PTF GROUP BY ANNO"

If those aren't fast enough, you'll have to move to a faster computer or a faster database system.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4364
Joined: 26 Apr 2010, 17:36

Re: speed up distinct selection....

Post by sal21 »

HansV wrote:Do you have an index on the ANNO field? That should help.

Try either

SQL = "SELECT DISTINCT ANNO FROM VIAGGIANTI_PTF"

or

SQL = "SELECT ANNO FROM VIAGGIANTI_PTF GROUP BY ANNO"

If those aren't fast enough, you'll have to move to a faster computer or a faster database system.
Yes i have index on ANNO and peraphs the second is a few fast!