php - Querying from Remote databases using an ORM ( ie. Eloquent ) -
i have come across situation querying 2 tables has 16k records each.
executing raw sql results in response time few seconds , if opt stick orm queries, same results in nginx request timeout since query takes more 1 min process.
has faced similar scenario , aware heavy queries can made using doctrine.
the implementation looks this. more detailed explanation on architecture in use: https://stackoverflow.com/a/19771835/540771
laravel app default connection connects db 1 (has connection details db 2). according correct connection connects appropriate db.
db 1:
connections table ( id, db_name, db_username, db_password, hostname, port)
db 2:
customer ( customer_id, name ) customer_details ( customer_id, email, etc ... )
the query executes on db 2 , looks like:
select * customers c left join customer_details cd on c.customer_id=cd.customer_id order c.created_at desc
the row count on table customers , customer details 16k each. relationship 1 .. * , business rules limit in way there 1 customer record maps 1 customer_details record.
the result fetched datatable. pagination added limit number of records returned.
Comments
Post a Comment