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 8757759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:22:48+00:00 2026-06-13T14:22:48+00:00

I created 3 tables like : db.execSQL(CREATE TABLE IF NOT EXISTS programs (id_program INTEGER

  • 0

I created 3 tables like :

db.execSQL("CREATE TABLE IF NOT EXISTS programs (id_program INTEGER PRIMARY KEY    AUTOINCREMENT , id_channel TEXT  , nom_prgrm TEXT  , debut TEXT , fin TEXT , FOREIGN KEY(id_channel) REFERENCES channels(id_channel)) ");
db.execSQL("CREATE INDEX __program_index ON programs(nom_prgrm)"); 
db.execSQL("CREATE TABLE IF NOT EXISTS categories (id_categorie INTEGER PRIMARY KEY  AUTOINCREMENT, nom_categorie TEXT)");
db.execSQL("CREATE UNIQUE INDEX __categorie_index ON   categories(nom_categorie,id_categorie)"); 
db.execSQL("CREATE TABLE IF NOT EXISTS categories_programs (id_categorie INTEGER REFERENCES categories(id_categorie) ,id_program INTEGER REFERENCES programs(id_program), PRIMARY KEY(id_categorie,id_program))");

programs table contains alomost 2500 records and categories 150 so the link table has 3400 rec

when i execute this query it takes a very long time to show me the result i don’t know how to optimiz this !!

SELECT  id_channel , nom_categorie , debut , fin , nom_prgrm FROM programs, categories_programs, categories WHERE ( (categories_programs.id_program = programs.id_program) AND (categories_programs.id_categorie = categories.id_categorie) AND  ('"+sentence+"' LIKE ('%' || nom_categorie || '%')))

probably it’s the join wich is causing this problem ??

thanks for help

My problem is solved i tried the same code on an android 4.1 and it worked very fast but with an S2 ( android 2.3) it was slow !

  • 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-13T14:22:49+00:00Added an answer on June 13, 2026 at 2:22 pm

    Probably the cause of the slowness is

    LIKE ('%' || nom...

    having the wildcard at the beginning will make the database to parse the whole contents on that column.

    Also, it would improve a bit if you prepare the statement and then bind the paramerer (though it will not be significant).

    [EDIT]

    If this is not the problem, you have to consider that you are evaluating the LIKE clause 3400 times (and you have only 150 categories).

    Try prefiltering the category table with something like :

    SELECT  id_channel , nom_categorie , debut , fin , nom_prgrm 
    FROM 
        programs, 
        categories_programs, 
        (select id_categorie,nom_categorie from categories where ('"+sentence+"' LIKE ('%' || nom_categorie || '%'))))
        categories 
    WHERE (categories_programs.id_program = programs.id_program) AND (categories_programs.id_categorie = categories.id_categorie)
    

    (I haven’t tested the query so it may have some typo)

    [/EDIT]

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

Sidebar

Related Questions

I'm creating two tables like this: CREATE TABLE abc ( id INTEGER NOT NULL
I have Created a table like CREATE TABLE [dbo].[tab1]( [Id] [int] NOT NULL, [Name]
I created a table without a primary key Like this: private static final String
I created a table like this CREATE TABLE pull_dtl ( source_schema VARCHAR2(4000), source_tablename VARCHAR2(4000),
I've created a table like this : create table tbl( address varchar(5000)); If i
I have a table created like this: CREATE TABLE rh857_omf.picture(MeasNr TINYINT UNSIGNED, ExperimentNr TINYINT
I have created an index on my table like this: CREATE INDEX index_typ_poplatky ON
I have two tables like, CREATE TABLE [dbo].[entry] ( [id] [int] NULL, [service] [int]
I have an sqlite database on android created like this: sqlite> .schema CREATE TABLE
I have created a php table like so: echo <table border = '0' cellpadding

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.