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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:14:41+00:00 2026-06-06T07:14:41+00:00

Here is my sample query: SELECT userid,count(*) FROM hits GROUP BY userid My table

  • 0

Here is my sample query:

SELECT userid,count(*)
FROM hits
GROUP BY userid

My table is something like this

id | userid | time …etc

Where id is the primary key and I use this table to store every visit on a page.
Which means my table has 200,000+ rows.

For a userid lets say X i want to find out on which rank it is in the query that means how many users have visited that page more than the user with that userid.

I know there are many questions LIKE this but they aren’t same because

  1. My Query has group by
  2. I tried quite a few answers here some don’t even return anything while others take 5-10 mins. I need it to be faster.

for any further doubts pls clarify in comments

Thanks

  • 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-06T07:14:45+00:00Added an answer on June 6, 2026 at 7:14 am

    Count/Group by in a query that’s expected to return multiple rows will get progressively slower because the query will still have to touch every row in the table. Generally, if you expect to do reports like this often, and you expect your table to continue to grow, you should begin rolling that value into a cached value (so you should store every result still, but you should also add to a counter on that user’s user record). Of course, this also begs the question of whether you have an index on your user_id column and a foreign key into your users table, which should speed that query up considerably.

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

Sidebar

Related Questions

Here is sample query SELECT name, sum(SELECT id FROM mytable WHERE cond='1' and cond2='2')
I have this query: SELECT DISTINCT(b.friend_id) AS possible_id FROM friends_friends a JOIN friends_friends b
Here is sample data <table class=sparql border=1> <tr> <th>abstract</th></tr> <tr> <td> Cologne is Germany&#39;s
Data: Here is sample table(TableA) data ID StartTime EndTime 1 2012-03-22 06:00:00.000 2012-03-22 06:30:00.000
Here's the sample code: class TestAO { int[] x; public TestAO () { this.x
Here is the sample data for test table I have [childId] [parentId] [present] 1
How could I improve this query? Please tell me all my options here as
I have a basic MySQL query: $getFeed = SELECT posts.postID, posts.postTitle, ..... FROM posts
I'm having some problems translating this query to use ZF's Zend_Db_Select : SELECT b.id,
Here are some sample records ID(UniqueIdentifier) UserId title description version parentid 8362AB94-946F-4092-97C2-ABD957CC2E20 3 title

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.