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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:12:16+00:00 2026-06-02T19:12:16+00:00

Currently I am having an issue with slow queries to my DB – query

  • 0

Currently I am having an issue with slow queries to my DB – query time varies from 0.0005 seconds to 70 seconds.

Currently my table structure with content is following:

CREATE TABLE IF NOT EXISTS `content` (
  `content_id` int(11) NOT NULL AUTO_INCREMENT,
  `content_url` text NOT NULL,
  `content_text` text NOT NULL,
  `seed_id` int(11) NOT NULL,
  `created_at` bigint(20) NOT NULL,
  `image` varchar(2000) DEFAULT NULL,
  `price` varchar(300) DEFAULT NULL,
  PRIMARY KEY (`content_id`),
  UNIQUE KEY `CONTENT_TEXT_UNIQUE` (`content_text`(255)),
  KEY `FK_SEED_CODE` (`seed_id`),
  KEY `CONTENT_TEXT_TIME_INDEX` (`content_text`(255),`created_at`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=111357870 ;


ALTER TABLE `content`
  ADD CONSTRAINT `FK_SEED_ID` FOREIGN KEY (`seed_id`) REFERENCES `seed` (`seed_id`) ON DELETE CASCADE ON UPDATE CASCADE;

Currently I have only 2 queries to Database:

SELECT seed.seed_code,content.content_id as id, content.content_url, content.content_text, content.created_at, content.image, content.price FROM content
        LEFT JOIN seed ON content.seed_id = seed.seed_id 
        WHERE seed.seed_switch = 1 AND seed.seed_status_id = 3 AND seed.seed_id in (
        SELECT seed_id FROM seed WHERE storage_id ='.$storage.') '.$filter.' ORDER BY content.content_id DESC, content.created_at DESC LIMIT 50

And

SELECT seed.seed_code,content.content_id as id, content.content_url, content.content_text, content.created_at, content.image, content.price FROM content
        LEFT JOIN seed ON content.seed_id = seed.seed_id 
        WHERE seed.seed_switch = 1 AND seed.seed_status_id = 3 AND seed.seed_id in (
        SELECT seed_id FROM seed WHERE storage_id ='.$storage.') ORDER BY content.content_id DESC, content.created_at DESC LIMIT 50

Table seed contains ± 20 entries. Which doesn’t change mostly.

Indexes created on content table seems not working, because still I am having very big load time.

What could be the improvements of DB?

UPDATE 1

The content tables contains around 1mil entries and it grows every day with 1-2k entries.

$filter variable contains additional filters. So some other AND statements, which are generated randomly depending of user input. But it filters only content.text and created_at date.


  • 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-02T19:12:19+00:00Added an answer on June 2, 2026 at 7:12 pm

    EDIT
    Ok, noticed the autoincrement in your create table. You have or have had millions of records (since increment is over 100 million) and are running a where-in subselect, not going to get ideal performance taking that approach. Try below query and see if that improves load times.

    You haven’t supplied all the details (for example, how many records the tables in question have and what the output of '.$filter.' is), but more than likely the subselect is the cause of the slow load time. Also, save yourself some typing and alias the tables! Cleaned up example:

    SELECT s.seed_code, c.content_id as id, c.content_url, c.content_text, c.created_at, c.image, c.price 
    FROM content c
    JOIN seed s USING(seed_id)
    WHERE s.seed_switch = 1 
      AND s.seed_status_id = 3 
      AND s.storage_id ='.$storage.'
      '.$filter.' 
    ORDER BY c.content_id DESC
    LIMIT 50
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi All I am currently having an issue calling a WCF service from a
I am currently having a strange issue with an application migrated from rails 2.3.8
I'm new in mysql and I'm currently having an issue with a query. I
I'm currently having a strange issue whereby all browsers except from Google Chrome are
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I'm currently having an issue while uploading a file from Html to my rest
I am currently having an issue with BackgroundWorker running on Windows Server 2003. I
I'm currently having an issue wrapping my brain around the notion of converting my
I'm currently having an issue storing mouse coordinates into an array in which a
I hope someone here can help me.. I am currently having a small issue

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.