On 19/10/2012 9:17 AM, Igor Tandetnik wrote:
Ryan Johnson <ryan.john...@cs.utoronto.ca> wrote:
I'd go for a user-defined aggregate taking two args: the key (to
identify "first") and the value to coalesce. Sure, it would never stop
the scan early, but the benefit of doing one scan instead of five
probability outweighs that (unless Steinar has an appropriate index on
every single column, which I doubt).
Or unless a non-null value is typically found in the first few rows of a large
table. In other words, if the ratio of nulls to non-nulls is small (and if it's
large, then I'd be thinking of a different schema, one that represents a sparse
table more efficiently).
I had assumed a sparse table because I'm having a hard time imagining
why you'd want to coalesce dense rows in this way. But you're right: in
that case you'd really want to store sparse columns in separate tables,
which would make the nested query approach by far the best (especially
if you alias the sparse table's foreign key with its rowid).
Ryan
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users