[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-06 Thread Petite Abeille
> On Mar 6, 2016, at 9:37 PM, James K. Lowden > wrote: > > I've never seen a system that provides queryable optimizer metadata. Oracle does, for a given definition of ? queryable?. > I don't remember ever having read a paper on the idea, either. I have to confess using query plans to get

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-06 Thread R Smith
On 2016/03/06 1:39 PM, Paul Sanderson wrote: > I understand this - but, there always a but, I still would like to do > something. Applying the limit anyway and then telling them the query > has been limited might be a solution. > > Time is usually not an issue but as the results are loaded into a

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-06 Thread James K. Lowden
On Sun, 6 Mar 2016 11:39:38 + Paul Sanderson wrote: > I understand this - but, there always a but, I still would like to do > something. Applying the limit anyway and then telling them the query > has been limited might be a solution. > > Time is usually not an issue but as the results are

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-06 Thread Paul Sanderson
I understand this - but, there always a but, I still would like to do something. Applying the limit anyway and then telling them the query has been limited might be a solution. Time is usually not an issue but as the results are loaded into a grid for display memory can be the issue. I'll give

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-06 Thread R Smith
On 2016/03/05 6:21 PM, Paul Sanderson wrote: > Thanks Richard > > so suppose I have two tables table1 and table2 each with 1000 rows and > say 100 columns some containing large blobs. > > My user choose a query "select * from table1, table2" > > I can modify the query and do a "select count(*)

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-05 Thread Tim Streater
On 05 Mar 2016 at 16:12, Richard Hipp wrote: > On 3/5/16, Paul Sanderson wrote: >> Clemens, >> >> Tim has the same issue as me, while >> >> SELECT EXISTS (select status from mytable where status=1); >> >> works the portion in brackets is still executed in full and this is >> what we are

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-05 Thread Paul Sanderson
Thanks Richard so suppose I have two tables table1 and table2 each with 1000 rows and say 100 columns some containing large blobs. My user choose a query "select * from table1, table2" I can modify the query and do a "select count(*) from table1, table2" to determine that 1M rows will be

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-05 Thread Clemens Ladisch
Tim Streater wrote: > On 05 Mar 2016 at 13:05, Clemens Ladisch wrote: >> But why do you want to determine the number of rows in the first place? > > In my case I want to know whether at least one row exists that has a certain > column which has a given value. At the minute I do this: > >

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-05 Thread Paul Sanderson
Clemens, Tim has the same issue as me, while SELECT EXISTS (select status from mytable where status=1); works the portion in brackets is still executed in full and this is what we are trying to avoid. I am not working directly with the sqlite library but rather though a DAC so I am also

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-05 Thread Tim Streater
On 05 Mar 2016 at 13:05, Clemens Ladisch wrote: > Paul Sanderson wrote: >> I am trying to determine before a query is executed how many rows will >> be returned. the following query works as expected >> >> select count(*) from table >> >> but >> >> select count(*) from table limit 100 >> >>

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-05 Thread Richard Hipp
On 3/5/16, Paul Sanderson wrote: > Clemens, > > Tim has the same issue as me, while > > SELECT EXISTS (select status from mytable where status=1); > > works the portion in brackets is still executed in full and this is > what we are trying to avoid. The query planner in SQLite, while not

[sqlite] Fastest way to find whether at least one row has a certain column value

2016-03-05 Thread Richard Hipp
On Sat, 05 Mar 2016 13:24 +, Tim Streater wrote: > > In my case I want to know whether at least one row exists that has a certain > column which has a given value. At the minute I do this: > > select count(*) from mytable where status=1 limit 1; > SELECT 1 FROM mytable WHERE status=1 LIMIT