menth0l has asked for the wisdom of the Perl Monks concerning the following question:
SELECT * FROM my_table WHERE col_1 IN (<large set of integers>) AND col_2 IN (<another large set of integers>)
DBD::SQLite::db prepare_cached failed: too many SQL variables
use List::MoreUtils qw/natatime/; sub select_in_chunks { my ($self, $set_1, $set_2) = @_; my @ret; my $chunk_size = 450; my $it1 = natatime $chunk_size, @$set_1; while (my @a = $it1->()) { my $it2 = natatime $chunk_size, @$set_2; while (my @b = $it2->()) { # previous query with subsets my $records = $self->query(\@a, \@b) push @ret, @$records; } } return \@ret; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SQLite and large number of parameters
by bart (Canon) on Dec 10, 2012 at 11:53 UTC | |
by menth0l (Monk) on Dec 10, 2012 at 13:07 UTC | |
by Jim (Curate) on Dec 10, 2012 at 19:26 UTC | |
by Anonymous Monk on Dec 10, 2012 at 16:40 UTC | |
|
Re: SQLite and large number of parameters
by moritz (Cardinal) on Dec 10, 2012 at 11:53 UTC | |
by menth0l (Monk) on Dec 10, 2012 at 13:40 UTC |