On 2017-08-25 17:43, Sannyasin Brahmanathaswami via use-livecode wrote:
@ Mark Waddingham
Awesome! thanks, I will test this later…
Yes, my solution, at the urging of our Cohorts of the Round Table
LiveCode Data Diggers,
who earlier said "Don't go looking for your needles in arrays." (
I just reformulated the SQL quaryand passed it back "up" to the stack
script which fetched the original complete data set.
That worked, but there are many use cases where this will be a better
in the context of songs I guess we iterate several times through this
example to a case where
[title %like% "laughter" OR subtitle %like% "laughter" OR description
genre = "Songs By Nerds"
theme = "Never Say Can't"
requires three trips to the mall:
array contains "Laughter"
array contains " Songs By Nerds "
array contains "Never Say Can't"
But these are very small data sets, relatively speaking.. so it will
be fast. But what serialization results is unclear…
Which is better (using arrays, or the DB direct) largely depends on the
size of the dataset.
If you have a very large dataset, then you are going to run out of
memory if you try and load it all into RAM - so a better approach (as
you have done) is to bind the search to SQL queries on the DB. This is
very scalable; and if you back everything you do with the (large)
dataset by the DB, you get 'only needing what you need in RAM at any one
time' essentially for 'free' (although, at the expense of needing to
abstract through SQL I suppose).
If you have a small dataset (which isn't going to grow, or only grow
very slowly) then it probably makes no difference, and you are better
off using whichever is easier to code.
In terms of generalizing that function - then the key line which checks
whether an element matches is:
else if tElement contains pNeedle then
One could imagine that this could be an arbitrary predicate - pNeedle
doesn't have to be a string, so could be an array representing a AND /
OR style query; or could be a regex (in which case you'd use matchText).
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your subscription