WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 9 months ago

#11375 closed enhancement (maybelater)

allow to disable the private status

Reported by: Denis-de-Bernardy Owned by: ryan
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Query Keywords: needs-patch performance
Focuses: Cc:

Description

The private status generates all sorts of OR clauses in SQL queries, which is bad from a performance standpoint.

Blogs that do not have any private posts or pages should have the ability to disable the feature altogether, in order to optimize the SQL statements.

Adding an option in a Settings page arguably is plugin material, but WP doesn't currently allow to remove the status altogether.

Were it to be implemented, WP should keep a trace (in a transient) of the following:

$has_private_posts = (bool) $wpdb->get_var("SELECT EXISTS 1 FROM $wpdb->posts WHERE post_status = 'private';");

checking its value and disabling the type = private type accordingly in non-admin areas would significantly enhance the user experience for those who never use such things.

Attachments (1)

has-private-posts.php (1.0 KB) - added by Denis-de-Bernardy 4 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 mrmist4 years ago

+1 to this idea.

Question though - how would such removal be dealt with, would it not introduce as many performance issues as it solves? I'm thinking e.g filtering out pre-existing private posts added before such functionality were enabled..

comment:2 Denis-de-Bernardy4 years ago

I'm using the attached function in a plugin. It makes things *much* faster for logged in users.

comment:3 Denis-de-Bernardy4 years ago

  • Keywords dev-feedback added

any interest from the core devs, or should I just close and keep it as a plugin?

comment:4 hakre4 years ago

I'm not a core dev, think this actually is usefull but since no core-dev has answered to your question it looks like close. So I suggest to close as "wont-enhance" :)

comment:6 voyagerfan57614 years ago

  • Cc WordPress@… added

comment:8 Denis-de-Bernardy4 years ago

  • Keywords bug-hunt added

comment:9 Denis-de-Bernardy4 years ago

  • Keywords featured added; bug-hunt removed

comment:10 miqrogroove4 years ago

  • Milestone changed from 3.0 to Future Release

I'm hoping #11914 will get a last-minute commit before beta. It touches some of the private query logic and should help, if anything.

As for this ticket, I don't see any momentum for the 3.0 beta. Let's clear it off the 3.0 plate and find someone to adopt the private post issues in 3.1.

comment:11 kovshenin15 months ago

  • Cc kovshenin added
  • Keywords editorial-flow added

This might be fixed by the work on post statuses in 3.6. See #23168

comment:12 follow-up: wonderboymusic9 months ago

  • Keywords needs-patch performance added; dev-feedback featured editorial-flow removed

just ran some tests: with any OR for post_status, it's about 2ms slower than just post_type = 'publish'

comment:13 in reply to: ↑ 12 nacin9 months ago

  • Milestone Future Release deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Replying to wonderboymusic:

just ran some tests: with any OR for post_status, it's about 2ms slower than just post_type = 'publish'

An EXPLAIN is going to be more informative than raw speed.

I'm going to close this as maybelater. It is realistically a duplicate of #12706, otherwise.

Note: See TracTickets for help on using tickets.