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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:50:21+00:00 2026-06-17T06:50:21+00:00

I’m writing on a small Android App with SQLite 3 support. ATM I’m implementing

  • 0

I’m writing on a small Android App with SQLite 3 support. ATM I’m implementing some DB-Functions and asking myself if it is better have one big joined query or if it is OK to use multiple queries in respect to App performance.

Let’s say I have a 3 Tables “drivers”, “driven_runs”, “race_disciplines”. Every driven_run has a driver and a race_discipline. Let’s assume I want to get all race disciplines by a certain driver in a certain discipline.

Solution 1

I already coded a function getDriver(driverID) with a Driver-Object in return and a function getRaceDiscipline(disciplineID) with a Race Discipline in return. So I would just create a function

public ArrayList<DrivenRun> getDrivenRunsOnDiscipline(short driverID, short disciplineID) {
    ArrayList<DrivenRun> drivenRuns = new ArrayList<DrivenRun>();
    String sql = "SELECT * FROM " + DBHelper.TABLE_DRIVEN_RUNS + " WHERE " 
            + DBHelper.DRIVEN_RUNS_COLUMN_DRIVER_ID + "=" + driverID + " AND " 
            + DBHelper.DRIVEN_RUNS_COLUMN_RACE_DISCIPLINE_ID + "=" + disciplineID + ";";
    Cursor result = rawQuery(sql);
    if (result.moveToFirst()) {
        do {
            Driver driver = getDriver(driverID);
            RaceDiscipline discipline = getRaceDiscipline(disciplineID);
            DrivenRun run = new DrivenRun();
            run.setDriver(driver);
            run.setDiscipline(discipline);
            run.setResult("WHATEVER");
            drivenRuns.add(run);
        } while(result.moveToNext());
    }
    return drivenRuns;
}

in this case there would be 3 queries executed on after another but the coding is much more simple.

Solution 2

I would create one big joined query like

String sql = "SELECT * FROM driven_runs CROSS JOIN drivers CROSS_JOIN race_disciplines WHERE driven_runs.driver_id=drivers.id AND driven_runs.race_discipline_id=race_disciplines.id"
Cursor result = rawQuery(sql);

and would manually create the Driver and DrivenRun Object.

This solution needs much more writing but only one query is executed (or does the DB executes 3 queries as well when joining 3 tables?)

Long story short, is it OK to go with solution 1 because in regards to performance there isn’t much of a difference?

  • 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-17T06:50:23+00:00Added an answer on June 17, 2026 at 6:50 am

    In general, go for the simpler code until there’s a good performance reason not to. Given that this is SQLite anyway, I don’t think there’s likely to be much performance difference, since the overhead for queries is pretty low.

    Premature optimization is the root of all evil.

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

Sidebar

Related Questions

I am writing an app with both english and french support. The app requests
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I have an array which has BIG numbers and small numbers in it. I
I am writing an app for my school newspaper, which is run completely online
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

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.