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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:21:17+00:00 2026-06-15T16:21:17+00:00

Before I show the query here are the relevant table definitions: CREATE TABLE phpbb_posts

  • 0

Before I show the query here are the relevant table definitions:

CREATE TABLE phpbb_posts (
    topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
    poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
    KEY topic_id (topic_id),
    KEY poster_id (poster_id),
);


CREATE TABLE phpbb_topics (
    topic_id mediumint(8) UNSIGNED NOT NULL auto_increment
);

Here’s the query I’m trying to do:

SELECT p.topic_id, p.poster_id 
FROM phpbb_topics AS t 
LEFT JOIN phpbb_posts AS p 
   ON p.topic_id = t.topic_id 
      AND p.poster_id <> ... 
WHERE p.poster_id IS NULL;

Basically, the query is an attempt to find all topics where the number of times someone other than the target user has posted in is zero. In other words, the topics where the only person who has posted is the target user.

Problem is that query is taking a super long time. Here’s the EXPLAIN for it:

Array
(
    [id] => 1
    [select_type] => SIMPLE
    [table] => t
    [type] => index
    [possible_keys] =>
    [key] => topic_approved
    [key_len] => 1
    [ref] =>
    [rows] => 146484
    [Extra] => Using index
)
Array
(
    [id] => 1
    [select_type] => SIMPLE
    [table] => p
    [type] => ref
    [possible_keys] => topic_id,poster_id,tid_post_time
    [key] => tid_post_time
    [key_len] => 3
    [ref] => db_name.t.topic_id
    [rows] => 1
    [Extra] => Using where; Not exists
)

My general assumption when it comes to SQL is that JOINs of any are super fast and can be done in no time at all assuming all relevant columns are primary or foreign keys (which in this case they are).

I tried out a few other queries:

SELECT COUNT(1) 
    FROM phpbb_topics AS t 
    JOIN phpbb_posts AS p 
        ON p.topic_id = t.topic_id;

That returns 353340 pretty quickly.

I then do these:

SELECT COUNT(1) 
    FROM phpbb_topics AS t 
    JOIN phpbb_posts AS p 
        ON p.topic_id = t.topic_id
            AND p.poster_id <> 77198;

SELECT COUNT(1) 
    FROM phpbb_topics AS t 
    JOIN phpbb_posts AS p 
        ON p.topic_id = t.topic_id
    WHERE p.poster_id <> 77198;

And both of those take quite a while (between 15-30 seconds). If I change the <> to a = it takes no time at all.

Am I making some incorrect assumptions? Maybe my DB is just foobar’d?

  • 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-15T16:21:18+00:00Added an answer on June 15, 2026 at 4:21 pm
    SELECT t.topic_id 
    FROM phpbb_topics AS t 
    JOIN phpbb_posts AS p1
       ON p1.topic_id = t.topic_id
          AND p1.poster_id = $poster_id
    LEFT JOIN phpbb_posts AS p2 
       ON p2.topic_id = t.topic_id 
          AND p2.poster_id <> $poster_id
    WHERE p2.poster_id IS NULL
    

    That made it a ton faster. I’m getting all the posts where the target user has posted with the topic info attached to that and then getting all the people other than the target who’ve posted.

    There’ll be lots of duplicates in the p1.poster_id column but since I’m not actually getting that row I figure duplicates in that column don’t matter a whole lot.

    Thanks!

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

Sidebar

Related Questions

I need to show a popup window before a query execution, show the time
I wanted to create a link that would show content before showing a direct
I'm trying to create a table in php that would show the data on
I have not used deferreds before but I've read a bit here and there
Well here is the situation, from the table before I running this code is
I am trying to make a quiz that should show questions not answered before
How to SELECT 3 table in one query and show all product with price?
I'm trying to show a UIAlertView before actually deleting a cell from a UITableView
I've written this code to show a prompt before a form is submitted. If
I am trying to show correlation between two individual lists. Before installing Numpy, I

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.