Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:56:07+00:00 2026-06-12T08:56:07+00:00

I’m using sqlite for a small validation application. I have a simple one table

  • 0

I’m using sqlite for a small validation application. I have a simple one table database with 4 varhchar columns and one integer primary key. There are close to 1 million rows in the table. I have optimised it and done a vacuum on it.

I am using the following query to retrieve a presence count from the table. I have changed the fields and names for privacy.

                  SELECT 
                  count(*) as 'test'
                  FROM
                  my_table
                  WHERE
                  LOWER(surname) = LOWER('Oliver')
                  AND
                  UPPER(address_line2) = UPPER('Somewhere over the rainbow')  
                  AND
                  house_number IN ('3','4','5');

This query takes about 1.5-1.9 seconds to run. I have tried indexes and they make no difference really. This time may not sound bad but I have to run this test about 40,000 times on a read in csv file so as you may imagine it adds up pretty quickly. Any ideas on how to reduce the execution time. I normally develop in mssql or mysql so if there are some tricks I am missing in sqlite I would be happy to hear them.

All the best.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:56:08+00:00Added an answer on June 12, 2026 at 8:56 am

    When you use a function over an indexed column, SQLite cannot use the index, because the function may not preserve the ordering — i.e. there can be functions such as 1>2, but F(1)<F(2). There are some ways to solve this situation, though:

    1. If you want to use indexes to make your query faster, you must save
      the value in a fixed case (upper or lower) and then convert only the
      query parameter to the same case:
    SELECT count(*) as 'test'
    FROM my_table
    WHERE surname = LOWER('Oliver')
    
    1. You can use the case-insensitive LIKE operator (I don’t know how indexes are affected!):
    SELECT count(*) as 'test'
    FROM my_table
    WHERE surname LIKE 'Oliver';
    
    1. Or you can create each column as text collate nocase and don’t worry about case differences regarding this column anymore:
    CREATE TABLE my_table (surname text collate nocase, <... other fields here ...>);
    SELECT count(*) as 'test'
    FROM my_table
    WHERE surname ='Oliver';
    

    You can find more information about the = and LIKE operators here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have a small JavaScript validation script that validates inputs based on Regex. I
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an array which has BIG numbers and small numbers in it. I
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.