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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:53:01+00:00 2026-05-26T08:53:01+00:00

so I have a 560mb db with the largest table 500mb(over 10 million rows)

  • 0

so I have a 560mb db with the largest table 500mb(over 10 million rows)

my query hase to join 5 tables and takes about 10 seconds to finish….

SELECT DISTINCT trips.tripid                                AS tripid,
                stops.stopdescrption                        AS "perron",
                Date_format(segments.segmentstart, "%H:%i") AS "time",
                Date_format(trips.tripend, "%H:%i")         AS "arrival",
                Upper(routes.routepublicidentifier)         AS "lijn",
                plcend.placedescrption                      AS "destination"
FROM   calendar
       JOIN trips
         ON calendar.vsid = trips.vsid
       JOIN routes
         ON routes.routeid = trips.routeid
       JOIN places plcstart
         ON plcstart.placeid = trips.placeidstart
       JOIN places plcend
         ON plcend.placeid = trips.placeidend
       JOIN segments
         ON segments.tripid = trips.tripid
       JOIN stops
         ON segments.stopid = stops.stopid
WHERE  stops.stopid IN ( 43914, 23899, 23925, 23908,
                         23913, 19899, 23871, 43902,
                         23876, 25563, 18956, 19912,
                         23889, 23861, 23879, 23884,
                         23856, 19920, 19898, 23916,
                         23894, 20985, 23930, 20932,
                         20986, 22434, 20021, 19893,
                         19903, 19707, 19935 )
       AND calendar.vscdate = Str_to_date('25-10-2011', "%e-%c-%Y")
       AND segments.segmentstart >= Str_to_date('15:56', "%H:%i")
       AND routes.routeservicetype = 0
       AND segments.segmentstart > "00:00:00"
ORDER  BY segments.segmentstart 

what are things I can do to speed this up? any tips are welcome, i’m pretty new to sql…
but I can’t change the structure of the db because it’s not mine…

  • 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-26T08:53:02+00:00Added an answer on May 26, 2026 at 8:53 am

    Just looking at the query, I would say that you should make sure that you have indexes on trips.vsid, calendar.vscdate, segments.segmentstart and routes.routeservicetype. I assume that there is already indexes on all the primary keys in the tables.

    Using explain as Briedis suggested would show you how well the indexes work.

    You might want to add covering indexes for some tables, like for example an index on trips.vsid where tripid and routeid are included. That way the database can use only the index for the data that is needed from the table, and not read from the actual table.

    Edit:

    The execution plan tells you that it successfully uses indexes for everything except the segments table, where it does a table scan and filters by the where condition. You should try to make a covering index for segments.segmentstart by including tripid and stopid.

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

Sidebar

Related Questions

Heylo! I have a video file (unknown compression) of about 500MB in size. I
I have a table that has 8 million records, with many fields, including lat/long
I have some json files with 500MB. If I use the "trivial" json.load() to
Have someone tried out DeCAL in Delphi 2009? I'm thinking about upgrading from 2007,
I'm trying to isolate duplicates in a 500MB database and have tried two ways
We have an application whose virtual memory rises and keep going for over a
I have an ASP.NET website that will hit about 2gb physical memory used within
When I transfer a file about 50Mb over HTTP sometimes I get this error:
I have a large file 500MB at the url http://domain.com/somefile.mxt . Because it's a
Linux noob question: If I have 500MB of RAM, and 500MB of swap space,

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.