Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Velocizzare query

  1. #1
    Utente di HTML.it L'avatar di Utente
    Registrato dal
    Dec 2005
    Messaggi
    197

    Velocizzare query

    Utilizzo questa query per estrarre alcuni dati dal database:

    codice:
    <%
    sql = "SELECT dato_a FROM tabella group by dato_a order by rand() limit 50"
    
    Set Rs = Conn.Execute(sql)
    
    while not rs.eof
    
    fsize=fsize
    
    if fsize > 6 then
       fsize = 1
    end if
    
    dato_a = lcase(Rs("dato_a"))
    
    'dato_a= (UCase(left(dato_a, 1)) & mid(dato_a, 2, len(dato_a)-1))
    
    %>
    
    <%=dato_a%>
    
    <%
    
    rs.movenext
    
    fsize=fsize+rnd(0.001)
    
    wend
    
    %>
    Ultimamente i dati da estrarre sono aumentati di molto e la query è molto molto lenta.

    Secondo voi è possibile migliorarla per aumentarne la prestazioni?


    Grazie

  2. #2
    Utente di HTML.it L'avatar di wallrider
    Registrato dal
    Apr 2003
    Messaggi
    2,755
    prova con
    "SELECT DISTINCT(dato_a), rand() as r from tabella order by r LIMIT 50"
    RIP Cicciobenzina 9/11/2010

    "Riseminaciceli, i ceci nell'orto"

  3. #3
    Utente di HTML.it L'avatar di Utente
    Registrato dal
    Dec 2005
    Messaggi
    197
    Purtroppo è ancora molto lenta...

  4. #4
    Utente di HTML.it L'avatar di wallrider
    Registrato dal
    Apr 2003
    Messaggi
    2,755
    select (select distinct dato_a FROM tabella limit 50) as datoa, rnd() as r order by r


    ?

    vado a caso eh
    RIP Cicciobenzina 9/11/2010

    "Riseminaciceli, i ceci nell'orto"

  5. #5
    Utente di HTML.it L'avatar di Utente
    Registrato dal
    Dec 2005
    Messaggi
    197
    Ottengo il seguente errore

    codice:
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'
    
    [MySQL][ODBC 5.1 Driver][mysqld-5.0.51b-community-nt]Subquery returns more than 1 row
    
    /dir.asp, line 26
    La riga 26 : Set Rs = Conn.Execute(sql)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.