Skip to main content

Posts

Showing posts with the label SQL

Cursor vs Offset Pagination: Optimizing Large Data Retrieval in REST APIs

  When a production database scales, few architectural choices cause as much silent degradation as standard   OFFSET   and   LIMIT   pagination. An endpoint that returns data in 20 milliseconds during testing can easily spike to multi-second response times in production when users navigate deep into a dataset. This latency spike, known as the deep pagination performance problem, is a direct result of how relational database engines execute offset commands. Fixing this requires shifting the API architecture from offset-based retrieval to keyset (cursor) pagination. The Mechanics of Deep Pagination Performance Degradation To understand why a REST API fails under deep pagination, you must examine the database execution plan. Relational databases like PostgreSQL and MySQL do not maintain a physical index of row offsets. When an API executes a query like  SELECT * FROM transactions ORDER BY created_at DESC LIMIT 50 OFFSET 500000; , the database engine cannot mat...

Fixing 'Access Denied' for Remote MySQL Connections on Hostinger

  There are few workflow interruptions more frustrating than setting up a local database client—be it DBeaver, MySQL Workbench, or DataGrip—only to be rejected by the server. You have the correct username, the correct password, and the correct hostname, yet the connection fails with standard errors like   ERROR 1045 (28000): Access denied   or   Connection refused . If you are hosting on Hostinger, this is a distinct, security-focused architectural feature, not a bug. By default, Hostinger (and most shared hosting providers) configures the MySQL daemon to reject all TCP/IP connections originating from outside the localhost environment. This guide provides the technical steps to bypass this restriction securely via hPanel and explains the networking logic governing these rejections. The Root Cause: MySQL Bind-Address and Firewall Rules To understand why your connection is failing, we must look at the MySQL server configuration file ( my.cnf ) and the network firewall....