Run specific select raw queries on write database in order to have fresh data on replication lag

Dimitrios Desyllas - Mar 9 '20 - - Dev Community

How I can arbitaty execute some raw sql queries on write host. I do need it in order to have the most fresh data. It won't be on all the queries but on handfull critical ones.

I use my Laravel 5.7 application a master-slave database replication scheme using postgresql:

'mydb' => [
    'driver' => 'pgsql',

    'read'  => [
        'host' => env('DB_HOST_READ', '192.168.2.3'),
    ],
    'write' => [
        'host' => env('DB_HOST_WRITE', '192.168.2.5'),
    ],
    'port'     => env('DB_PORT', '5432'),
    'database' => env('DB_DATABASE', 'mydb'),
    'username' => env('DB_USERNAME', ''),
     'password' => env('DB_PASSWORD',

DO you have any idea?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player