Slave Only Read from Tabel

Open
#96 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
mysql, php, wordpress
Domain
databases

Research direction

Start by reading HyperDB's $wpdb->add_database() and $wpdb->add_callback() entry points, then trace how table names are used when selecting a connection. Done means establishing whether read-only routing can be limited to wpoa_posts and wpoa_postmeta or exclude other tables, and documenting a working configuration or the limitation.

Written by the indexing model from the issue text.

Description

Hello,

I want to use my slave server only for 2 tables. But can't find a suitable guide and this code doesn't seem to work, can anyone help?
Is it possible to also specifically exclude tables?

Ok I will use only Read Modus on wpoa_posts and wpoa_postmeta on a Mysql 8 Slave for more Performance, the table posts and postmeta are very big size.

thanks in advance
Manu

`$wpdb->add_database( array(
'host' => '127.0.0.1:3380',
'user' => 'blog_user',
'password' => 'pass',
'name' => 'sport',
'dataset' => 'testme',
'write' => 0,
'read' => 1,
) );

$wpdb->add_callback( 'my_db_callback' );
function my_db_callback( $query, $wpdb ) {
if ( preg_match("/wpoa_post%/", $wpdb->table) ) {
return 'testme';
}
}`

Dominant language
PHP
Stars
150
Forks
28
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/HyperDB

All issues in Automattic/HyperDB

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.