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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:18:46+00:00 2026-06-13T23:18:46+00:00

I have the following query running against a MySQL db every 30 seconds: SELECT

  • 0

I have the following query running against a MySQL db every 30 seconds:

SELECT message.id FROM message WHERE userto='13689' AND tstampviewed IS NULL AND message.status != 'VOID';

It shows up in my slow query log a lot, but it looks to me like it is optimized as best as can be.

The result of EXPLAIN:

SELECT_TYPE = Simple

TABLE = message

TYPE = ref

POSSIBLE_KEYS = userto,tst,stat

KEY = userto

KEY_LEN = 53

REF = const

ROWS = 1

EXTRA = “Using Where”

The keys userto, tst, and stat are all normal BTREE indexes, one for each of the varchar fields referenced in the whereclause of the query. It is a MyISAM table with 300K rows. Users do write to the table consistently, but reads are much more likely (10/1 ratio of reads to writes). The db server is Windows 2008 Enterprise with a lot of CPU and fast drives.

Over the past month, we keep getting max_connection errors, even though I increased the max_connections from 750 to 1500. Several times a day, it seems like a query hangs (I can’t verify this because I don’t have access to the process list in real time), and 1500 queries pile up behind it and max out the connections. This then obviously causes a lot of other problems.

The above query is the one that consistenly comes up in the slow query log, even though I thought it was optimized as best as possible. Can anyone tell me otherwise or point me in the right direction to solve this problem?

Thanks in advance.

  • 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-13T23:18:47+00:00Added an answer on June 13, 2026 at 11:18 pm

    The problem is not on the query – you are opening a connection to the database and not closing it, but opening a new one each time.

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

Sidebar

Related Questions

I have the following query running against a mysql database: select value from fact_data
I have the following the query running dynamically SELECT * FROM Vehicles WHERE (DKID
I have the following query that running in SQLyog SELECT * FROM mytable WHERE
I have the following mysql query which I am running with php like so.
I have following query: $query=SELECT language_value, votes, user_id FROM labels WHERE approved=1 AND label_value=.
I have following query , select * from process where name like 'abc'; now
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
I have the following query to count all data every minute. $sql= SELECT COUNT(*)
I have the following query: SELECT item.`ID`, item.`Name`, item.`UnitCost`, item.`Price`, discount.`rate` FROM item INNER
I have the following query running on a classic asp page. sSQL = Select

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.