Information générale
Catégorie:
Codage, syntaxe et commandes
>>>There's no other function to search for a value in an array, you're probably going to have to order the array and then compare all the values one by one.
>>>
>>>Either ASORT() or adding ORDER BY to your select would give you an ordered array that you can work with for this.
>>
>>If you "compare all the values one by one," there is no benefit from ordering the array. If you do a binary search of the array, the ordering is required and the search will be extremely efficient and will outperform an ascan() after arrays reach about 3000 rows.
>
>I suppose you're right, if you compare all the values. But the idea was to find any value greater or equal to the user-specified criteria, so the ordering of the array is also required on this case.
You still have to step through all elements because he wants to return the subset of greater values. Ordered set: sequential seach for first greater than, sequential step to end. Non ordered set: sequential step to end with compare of each element. Is the sort faster than the additional compares? Depends on how close to the end of the sorted list the first greater tan value is.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement