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

  • Home
  • SEARCH
  • 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 8749815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:45:28+00:00 2026-06-13T12:45:28+00:00

I have the below query: SELECT ID FROM `Article` this_ WHERE (this_._Temporary_Flag = FALSE

  • 0

I have the below query:

 SELECT ID FROM 

`Article` this_ WHERE
(this_._Temporary_Flag = FALSE OR this_._Temporary_Flag = NULL) AND 
 this_.Published = TRUE AND
  (this_.PublishedOn IS NULL OR this_.PublishedOn <= '2012-10-29 08:54:36') AND 
  (this_.Deleted = FALSE OR this_.Deleted = NULL) AND 
  (this_._ComputedDeletedValue = FALSE OR this_._ComputedDeletedValue = NULL) AND 
  ((this_._TestItemSessionGuid IS NULL OR this_._TestItemSessionGuid = '')) AND 
  NOT (this_.CategoryId IS NULL) 
  AND (this_.PublishedOn < '2012-09-10 00:00:00' AND this_.CategoryId = 51118080)
   ORDER BY this_.PublishedOn DESC LIMIT 1

The table in question contains 141,505 records to be exact. I’ve checked the indexes and all of the fields mentioned in the WHERE clause and ORDER BY are indexed (Index Kind: INDEX, Index Type: BTREE).

This query takes 40seconds to run for the first time. Subsequent runs are down to 1 – 2sec, which I am assuming is due to caching. If I restart the MySQL Server, it again takes approximately 40 seconds again. Any ideas why it is performing so slow, and any optimisations that can be done?

Update 1

Database is MySQL, and table storage engine is InnoDb.

Update 2

As a side-note, the scope of this query is to get the ‘previous article’, related to the current one. I am doing this by getting all the articles which have their PublishedOn field less than the current ones, ordering by the PublishedOn descending and taking the first 1 (I updated the LIMIT as by mistake I originally entered it 50, when it should be 1).

The other conditions are to load only valid articles, and articles in the same category.

Update 3: EXPLAIN output

SelectType = Select
Type = index_merge
Possible_keys = CategoryId,PublishedOn,_TestItemSessionGuid,Deleted,_ComputedDeletedValue,_Tempo‌​rary_Flag,Published Key = Deleted,_ComputedDeletedValue,_Temporary_Flag,Published,CategoryId
Key_Len = 1,1,1,1,9
ref = (NULL)
Rows = 3383
Extra = Using intersect(Deleted,_ComputedDeletedValue,_Temporary_Flag,Published,CategoryId); Using where; Using filesort ______
  • 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-13T12:45:29+00:00Added an answer on June 13, 2026 at 12:45 pm

    Make sure you have (1) indexed your table fields and (2) Partition table e.g table field PublishedOn are best to partition by range You may refer to
    http://dev.mysql.com/doc/refman/5.1/en/partitioning-range.html for more details.

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

Sidebar

Related Questions

I have the below query in a postgresql database SELECT * FROM accounts where
I have written this query for retrieving data from mysql as below select FeedbackCode,EMailID,FeedbackDetail,
I have tried the below query: select empno from ( select empno from emp
I have the below query: SELECT p.id as prod_id, * FROM products AS p
I have a below query: select count(*) c , id from hr where time
I have below SQL query: SELECT * FROM ( SELECT S.aCol, S.bCol, S.cCol, ROW_NUMBER()
Heya!, I have the below query: SELECT t1.pm_id FROM fb_user_pms AS t1, fb_user_pm_replies AS
I have a problem with the query below in postgres SELECT u.username,l.description,l.ip,SUBSTRING(l.createdate,0,11) as createdate,l.action
I have some problem regarding the search in mysql. Below is my query. SELECT
I have below query I am trying to show message 'No SubSource for this

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.