If I switch name and profile_id in the index creation, I get the error you mentioned, but only if no other index has been yet defined. I am not sure this is the intended behaviour.#!/usr/bin/perl use warnings; use strict; use DBI; unlink 'test.db' or warn $!; my $dbh = DBI->connect('dbi:SQLite:test.db', q(), q()); $dbh->do(q(create table profile (profile_id integer, name varchar))); $dbh->do(q(create index idx_name on profile (name, profile_id))); my $insert = $dbh->prepare(q(insert into profile values(?, ?))); $insert->execute(@$_) for [10, 'Joseph'], [11, 'William'], [12, 'Elisabeth']; my $sql = q{ SELECT profile_id FROM profile INDEXED BY idx_name WHERE name == ? }; my $sth = $dbh->prepare($sql); my $name = 'William'; $sth->execute($name); my $arr = $sth->fetchall_arrayref; print "@$_\n" for @$arr;
In reply to Re: "Can't use index" with DBD::SQLite
by choroba
in thread "Cannot use index" with DBD::SQLite
by LonelyPilgrim
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |