You may find it faster to do:
select c from t where rowid in (list-of-constants)
and generate the list of constants using something like a blackrock
permutation generator. That takes linear time, whereas all the order-by
variants are n.log(n). You need some sort of row-id generator function,
Good idea but if there is no AUTOINCREMENT you can simply get the
min/max directly:
I think the following works (and for both + and - rowid's)
NB: The MaxRowID is not needed
with Rows(MinRowID, NumRows) as (select min(RowID) as MinRowID,
max(RowID) -
Yes, and the database will store the data as entered/bound if it cannot be
converted to the requested storage type (column affinity).
This is VERY IMPORTANT for you to understand fully and completely including all
the rules for storage class and affinity conversions and how they are
On May 31, 2018, at 6:32 PM, Roger Binns wrote:
>
> On 31/05/18 10:15, Richard Hipp wrote:
>> Size is still important. But having useful features is important too.
>> I'm continuing to work to find the right balance between these
>> competing goals.
>
> A pattern used in other projects is to
Good idea but if there is no AUTOINCREMENT you can simply get the min/max
directly:
I think the following might work (and should work for both + and - rowid's)
with Rows(MinRowID, MaxRowID, NumRows) as (select min(RowID) as MinRowID,
??
SELECT * FROM table WHERE id IN (SELECT id FROM table ORDER BY RANDOM() LIMIT x)
Maybe. It is more memory efficient then trying to sort the entire lot of data.
On Thu, May 31, 2018 at 7:13 PM Torsten Curdt wrote:
> I need to get some random rows from a large(ish) table.
>
> The following
Here's my two cents. Don't spend it all in one place...
CREATE TABLE [RandomTable](
[PriID] INTEGER PRIMARY KEY AUTOINCREMENT,
[DataCol] CHAR);
INSERT INTO [RandomTable]([PriID], [DataCol]) VALUES(1, 'a');
INSERT INTO [RandomTable]([PriID], [DataCol]) VALUES(2, 'b');
INSERT INTO
1. Define in documentation as < 1Mb. (Don't have to visit again.)
2. Continue to strive to keep in the 0.5-1MB range.
3. Add some information on building a MINIMUM size for those
concerned that is relatively easy to accomplish without
a lot of expertise if possible.
danap.
Currently I do not have SQLite setup to run on its own on a computer.
I figured the answer to my question would be faster if it was posed
to this list.
Given:
CREATE TABLE exdate (
id INTEGER,
mydate DATE NOT NULL,
PRIMARY KEY (id)
);
Once a number, numeric, is stored. Can a command line
Just an idea:
If the table has an INTEGER PRIMARY KEY AUTOINCREMENT then then maximum rowid
is available in the sqlite_sequence table.
To generate a random sequence of rowids, this can be used, somewhat like
SELECT DISTINCT rnd() * (SELECT seq FROM sqlite_sequence WHERE
name='') as rowid;
10 matches
Mail list logo