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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:21:13+00:00 2026-06-13T19:21:13+00:00

Hi I was hoping I could get some help on how to optimize my

  • 0

Hi I was hoping I could get some help on how to optimize my database so it doesn’t take a year. I know that to speed it up I need to add indexes, but I’m not exactly sure on what I should be adding them on.

Heres the three tables in my database:

CREATE TABLE IF NOT EXISTS `journeyPattern2` (
  `journeyPatternId` int(11) NOT NULL AUTO_INCREMENT,
  `serviceId` int(11) NOT NULL,
  `direction` enum('inbound','outbound') NOT NULL,
  PRIMARY KEY (`journeyPatternId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `journeyPatternTimingLink2` (
  `journeyPatternTimingLinkId` int(11) NOT NULL AUTO_INCREMENT,
  `journeyPatternId` int(11) NOT NULL,
  `from` varchar(15) NOT NULL,
  `to` varchar(15) NOT NULL,
  `direction` enum('inbound','outbound') NOT NULL,
  `runTime` varchar(15) NOT NULL,
  PRIMARY KEY (`journeyPatternTimingLinkId`),
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

CREATE TABLE IF NOT EXISTS `line` (
  `lineId` int(11) NOT NULL AUTO_INCREMENT,
  `serviceId` int(11) NOT NULL,
  `lineName` tinytext NOT NULL,
  PRIMARY KEY (`lineId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

CREATE TABLE IF NOT EXISTS `service` (
  `serviceId` int(11) NOT NULL AUTO_INCREMENT,
  `serviceCode` varchar(50) NOT NULL,
  `registeredOperatorRef` varchar(50) NOT NULL,
  `origin` tinytext NOT NULL,
  `destination` tinytext NOT NULL,
  PRIMARY KEY (`serviceId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

The table journeyPattern2 contains about 33000 rows, journeyPatternTimingLink2 contains around 13 million, and line and service around 70000.

The query I’m trying to optimize is the following

SELECT DISTINCT lineName,line.serviceId  FROM `journeyPatternTimingLink2` 
INNER JOIN journeyPattern2
ON journeyPattern2.journeyPatternId=journeyPatternTimingLink2.journeyPatternId
INNER JOIN line
ON journeyPattern2.serviceId = line.serviceId
WHERE `from` = '13006785E'

I’ve never really worked with tables of this size before so I’m not sure if I’m joining correctly in the first place. I’ve also uploaded a screenshot of me running EXPLAIN on the query from phpmyadmin, but I’m not exactly sure how to interpret the results so any help would be appreciated.

Thanks for your help.

  • 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-13T19:21:15+00:00Added an answer on June 13, 2026 at 7:21 pm

    You should add some indexes to these fields –

    • journeyPatternTimingLink2.journeyPatternId
    • journeyPattern2.serviceId
    • line.serviceId
    • journeyPatternTimingLink2.from

    These are indexes used in JOIN-ON clauses and WHERE condition.

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

Sidebar

Related Questions

hoping to get some help here. I have locations on a database that I
I was hoping I could get some help from you guys. The code below
I was hoping I could get some help figuring out why a bit of
I was hoping I could get some help with a Query I am trying
I was hoping I could get some help on the following problem. Basically, I
I was hoping I could get some help optimizing the following data retrieval. Here
I am hoping to get some help solving a problem that I'm sure many
Was hoping I could get a bit of a hand on this login that
I'm hoping to get some help with this weird problem. We're running the Jacorb
I have been playing with generics and was hoping I could get some feedback

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.