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

  • Home
  • SEARCH
  • 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 6064069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:14:23+00:00 2026-05-23T09:14:23+00:00

I have a sqlite db that at the moment has few tables where the

  • 0

I have a sqlite db that at the moment has few tables where the biggest one has over 10,000 rows. This table has four columns: id, term, definition, category. I have used a FTS3 module to speed up searching which helped a lot. However, now when I try to fetch ‘next’ or ‘previous’ row from table it takes longer than it was before I started using FTS3.

This is how I create virtual table:

CREATE VIRTUAL TABLE profanity USING fts3(_id integer primary key,name text,definition text,category text);

This is how I fetch next/previous rows:

SELECT * FROM dictionary WHERE _id < "+id + " ORDER BY _id DESC LIMIT 1
SELECT * FROM dictionary WHERE _id > "+id + " ORDER BY _id LIMIT 1

When I run these statements on the virtual table:

  • NEXT term is fetch within ~300ms,
  • PREVIOUS term is fetch within ~200ms

When I do it with normal table (the one created without FTS3):

  • NEXT term is fetch within ~3ms,
  • PREVIOUS term is fetch within ~2ms

Why there is such a big difference? Is there any way I can improve this speed?

EDITED:
I still can’t get it to work!

  • 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-05-23T09:14:24+00:00Added an answer on May 23, 2026 at 9:14 am

    Virtual table you’ve created is designed to provide full text queries. It’s not aimed to fast processing standard queries using PK in where condition.
    In this case there is no index on your _id column, so SQLite probably performs full table scan.
    Next problem is your query – it’s totally inefficient. Try something like this (untested):

    SELECT * FROM dictionary WHERE _id = (select max(_id) from dictionary where _id < ?)
    

    Next thing you can consider is redesign of your app. Instead of loading 1 row you, maybe you should get let’s say 40, load them into memory and make background data loading when there is less than n to one of the ends. Long SQL operation will become invisible to user even if it’ll last 3s instead of 0,3s

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

Sidebar

Related Questions

I have a script that appends some rows to a table. One of the
In my application I have a sqlite database that looks like this: CREATE TABLE
I have an SQLite table that contains a BLOB I need to do a
I have a database file that is generated on a PC using Sqlite. This
I have created a Python module that creates and populates several SQLite tables. Now,
I have a sqlite (v3) table with this column definition: timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
I have a remote database (at the moment sqlite, but eventually mysql) that I
I have an sqlite table that I'd like to add a new field to.
I have a small project that require a storage (I choose SQLite) and I
I'm starting a web project that likely should be fine with SQLite. I have

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.