On Sun, 25 Jun 2006 18:24:50 -0700 (PDT), onemind wrote:

>It took over 8 hours, so if anyone could tell me a text command that would
>do this same task of importing a txt file into a table through the sqlite3
>command line that would be great. It must be the gui slowing it down
>somehow.

Repeating details from my earlier post:
--------------------------
create table wordlist (word text);

select current_time;

begin transaction;

insert into wordlist values ("test0");
insert into wordlist values ("test1");
...
insert into wordlist values ("test199998");
insert into wordlist values ("test199999");
commit transaction;

select current_time;

select count(*) from wordlist;
--------------------------

It took 8 SECONDS, not 8 HOURS.

The above lines were taken directly from the
text file that I had created and then imported
into the sqlite3 command line utility by typing
the command:

        .read word.lst

The only change for this email was to delete
the 199,996 intermediate text lines that would
just get in the way of this example.


The suggestion made to use a bitset is an
excellent one. Put an index on the bitset field.
The sql AND operator will find all combinations
very quickly.

Here is sample code to create the content of
the bitset field from the characters in each word.
If you wrap this into a small program that reads
the word list and creates the above insert
statements then you can also insert the bitset
value as a second field in each insert statement.

unsigned long int
GetBitSetOf (char * InWord)


  int J, K;
  unsigned long int BitSet;     // must be at least 26 bits wide

  K = strlen(InWord);
  BitSet = 0;
  for (J = 0; J < K; J++) {
    BitSet |= 1 << (InWord[J] - 65);    // assumes all letters are uppercase 
only
  }
  return (BitSet);
} // GetBitSetOf




Reply via email to