xwp / stream

🗄️ Stream plugin for WordPress
https://wordpress.org/plugins/stream/
GNU General Public License v2.0
405 stars 117 forks source link

Offload database management to secondary database, thinking about `hyperdb`, `ludicrousdb`. #1360

Open saas786 opened 1 year ago

saas786 commented 1 year ago

Feature Request

As I see you are already using \WP_Stream\DB_Driver_WPDB, which can be be made pluggable.

ref: https://github.com/xwp/stream/blob/3.9.1/classes/class-db-driver-wpdb.php#L13

So for starters, something like this:

before:

public function __construct() {
...
        global $wpdb;
        $prefix = apply_filters( 'wp_stream_db_tables_prefix', $wpdb->base_prefix );
...
}

after:

public function __construct() {
...
        global $wpdb;

        $custom_$wpdb = apply_filters( 'wp_stream_db_tables', $wpdb );
        $prefix = apply_filters( 'wp_stream_db_tables_prefix', $custom_$wpdb->base_prefix );
...
}

ref: https://github.com/xwp/stream/blob/3.9.1/classes/class-db-driver-wpdb.php#L41

So where ever $wpdb is referenced, we could replace it if needed.

Reason

We have about 15 million entries for Stream, which is not ideal, slows down our website significantly, so would like it to be offloaded, so it can store / retrieve data from secondary database.

Loom_MSiJQj5Ptk

lkraav commented 1 year ago

slows down our website significantly

Where is this coming from? Queries are indexed and have very little effect on page build speed.

saas786 commented 1 year ago

slows down our website significantly

Where is this coming from? Queries are indexed and have very little effect on page build speed.

This might not apply to your website.

But not everyone has the luxury of using Powerful Servers, Indexing, Redis or such caching tools on their hands.

Majority of users are on shared hosting, with not access to caching tools like Redis etc.

So offloading logging to secondary database is necessary for the most users.

lkraav commented 1 year ago

So offloading logging to secondary database is necessary for the most users.

Those most users would highly likely also lack the capability to work with any secondary database.

But let's see what Stream team thinks here.