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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:31:56+00:00 2026-06-12T08:31:56+00:00

i am running into a problem, i have huge database and now i cant

  • 0

i am running into a problem, i have huge database and now i cant make changes i need to process all this data first. Problem is that each query which is writen below takes about 1-2 Minutes. If anyone know how to make a optimized select i would apprichiate it.

select distinct x.peerId
,(select max(id) from checkPeer where peerId=x.peerId) as idd 
from checkPeer x where x.id>0 order by x.id desc

Is there way to optimize this select from below defined table?

CREATE TABLE `checkPeer` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`peerId` varchar(100) COLLATE utf8_bin DEFAULT NULL,
`peerDate` datetime DEFAULT NULL,
`peerUrl` bigint(20) DEFAULT '0',
`peerState` bigint(20) DEFAULT '0',
`peerMessage` varchar(500) COLLATE utf8_bin DEFAULT NULL,
`peerResource` varchar(5000) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `peerId` (`peerId`),
KEY `peerUrl` (`peerUrl`)
) ENGINE=MyISAM AUTO_INCREMENT=688791 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

Thank you!

  • 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-12T08:31:58+00:00Added an answer on June 12, 2026 at 8:31 am

    a few immediate suggestions, remove DISTINCT and try the following:

    select x.peerId, x1.id as idd 
    from checkPeer x 
    left join
    (
        select max(id) id, peerid
        from checkPeer
        group by peerid
    ) x1
        on x.peerid = x1.peerid
    where x.id>0 
    order by x.id desc
    

    The above works great, if you wind up needing more fields but you stated you only need the two so you can try:

    select peerId, max(id) as idd
    from checkPeer 
    where id > 0
    group by peerid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been running into this problem a lot lately. I have an NSMutableArray called
I'm trying to turn a huge spreadsheet of data into a database to make
I have been running into a problem with python's re module. This is the
I have been running into this problem sometimes when programming. Imagine I have a
Running into a problem. I have a table defined to hold the values of
I'm running into a problem where, I have a Window that contains a child
So I have been running into all kinds of interesting problems in VisualStudio 2008
I'm running into the problem of users being able to submit data with '
I'm running into this problem when trying to call a SOAP Web Service from
We're running into the same problem as reported here: PDF Export Huge Report We're

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.