April 2023 Summaries
11 posts from PlanetScale
Filter
Month:
Year:
Post Summaries
Back to Blog
Rust has delivered memory safety without compromising speed, delivering benefits such as no garbage collector to improve performance. Rust is gaining relevance in backend development due to its ability to provide memory safety and performance. To build a Rust bird-watching API powered by a PlanetScale MySQL database, the guide assumes a basic knowledge of Rust and sets up a new project using Cargo. The guide then connects the project to the database using Diesel as an ORM, exposes endpoints using Rocket, and adds features such as adding, viewing, and removing bird sightings.
Apr 27, 2023
1,961 words in the original blog post.
PlanetScale offers three-way merge for schema changes in its database model, making it simpler and safer to collaborate on schema changes. This is similar to Git's three-way merge concept but has a different implementation. The process involves creating a deployment request, which generates a semantic diff of the changes made between the main branch (production) and the developer's branch. Three-way merge compares these two branches using the main branch as a base and determines if there are conflicts, overlaps, or no impact from one another. This allows for more efficient collaboration and reduces friction in deploying schema changes to production, while also providing early warnings of potential conflicts. PlanetScale disregards index ordering and considers identical or partial overlap between diffs to further reduce developer friction.
Apr 26, 2023
1,974 words in the original blog post.
The text discusses how PlanetScale Insights provides time-series metrics on a per-query pattern basis to help developers identify and troubleshoot problematic queries in their database. Query patterns are defined by normalizing SQL queries using Vitess's SQL parser, which extracts literals and eliminates surface-level syntactic differences. The normalized query is then used to calculate a fingerprint, group queries, and emit aggregated telemetry such as execution time and rows read or written. This feature allows developers to analyze performance issues in their database, identify areas for improvement, and optimize their query usage.
Apr 20, 2023
918 words in the original blog post.
The text discusses MySQL for application developers, emphasizing enhancing query performance. It begins with a general overview of MySQL and then proceeds to practical examples to apply the acquired knowledge.
Apr 20, 2023
38 words in the original blog post.
SELECT only what you need, whether it's by limiting the columns returned or by pagination. Deterministic ordering is crucial for effective pagination. There are two primary ways to paginate in MySQL: offset/limit and cursors. Offset/limit pagination can be slower as you navigate deeper into the pages and is more prone to drift. Cursor-based pagination is more performant and resilient to shifting rows, but it's more complicated to implement and cannot directly address pages. The choice of pagination method depends on your specific use case and application requirements.
Apr 18, 2023
3,649 words in the original blog post.
You can safely make database schema changes by adopting smaller, more frequent changes, ensuring backward compatibility at all steps of the process, using feature flags, branching, deploy requests with automated linting and checks for conflicts, non-blocking schema changes, gated deployments, revert features, insights into query performance, and automatic backups. These measures help reduce the risk of downtime and data loss associated with database schema changes, making it easier to release new features regularly while maintaining a stable application.
Apr 13, 2023
1,945 words in the original blog post.
Sharding is a technique used to scale out relational databases by storing partitions of data across multiple servers instead of putting everything on a single server. This allows for more efficient use of resources and improved scalability. Sharding can be done at different levels, such as row-level (horizontal) or schema-level (vertical), and involves deciding how to split up data into shards based on the business model and query load. The process of sharding includes planning and executing a migration, building a routing layer to direct queries to the correct databases, and managing hotspots where servers become overloaded with data. While some teams build their own sharding solutions from scratch, there are also tools and frameworks available, such as Vitess for MySQL and Citus for Postgres, that can simplify the process. The trend of using "serverless" databases, which automatically handle sharding and scaling, is gaining traction, offering an alternative to traditional sharding approaches.
Apr 06, 2023
2,004 words in the original blog post.
Sharding is a strategy for scaling out relational databases by storing partitions of data across multiple servers instead of putting everything on a single giant one. It involves deciding on a sharding scheme, organizing the target infrastructure, creating a routing layer, and planning and executing the migration to a sharded solution. There are various sharding schemes and algorithms, including hash-based, range-based, and directory-based sharding. Sharding maintenance is crucial as it requires managing hotspots and redistributing data and load. Routing queries to the right databases is also essential, which can be achieved through application logic or using tools like ProxySQL. The migration process involves double-writing, backfilling, verifying, and switching over to the new database. Several sharding frameworks and tools are available, including Vitess for MySQL and Citus for Postgres, which provide a layer on top of the relational databases to give them sharding capabilities. Additionally, serverless databases like CockroachDB are emerging as an alternative solution that can handle scaling out natively.
Apr 06, 2023
2,141 words in the original blog post.
We just released an update to our branching workflow: safe migrations. This feature enables direct DDL on production branches, allowing for non-blocking schema changes while minimizing downtime and potential data loss. Existing databases have been automatically enabled with safe migrations, and users can now turn it on when promoting a branch to production. The introduction of safe migrations aims to improve the user experience by providing more flexibility in database management, especially for developers who use workarounds to run direct DDL on their production databases. This update benefits users in various scenarios, including early development, frameworks with built-in migrations, and CMS platforms like WordPress, which may require running DDL on production databases. The goal of safe migrations is to provide a more accessible and user-friendly database management workflow while maintaining the stability and availability of PlanetScale's services.
Apr 05, 2023
797 words in the original blog post.
Versioned schema migrations involve using multiple files or scripts to document and apply changes to a database schema over time, functioning similarly to version control systems like Git. Typically stored alongside code, these migration files are applied incrementally using third-party tools, with a dedicated database table tracking which scripts have been executed. An example with the Laravel framework demonstrates how Artisan commands manage migrations, creating and altering database tables while tracking changes in a migrations table. Benefits of this strategy include familiarity for developers, ease of reverting changes, and straightforward tracking of incremental updates. However, drawbacks include difficulty in visualizing the entire schema at a given time and potential issues if schema modifications occur outside the migration tool. With platforms like PlanetScale, developers can use safe migrations to ensure zero-downtime and secure schema updates, leveraging branching and deploy requests to manage changes effectively.
Apr 05, 2023
1,549 words in the original blog post.
Declarative schema migrations offer a streamlined approach to managing database changes by using configuration files that can be easily modified and applied through command-line interface tools, similar to Infrastructure as Code (IaC) practices. This method provides several benefits, including a single source of truth for the schema, ease of understanding for developers unfamiliar with Data Definition Language (DDL), and simplified automation within continuous deployment processes. However, it also presents challenges such as potential conflicts from simultaneous changes by multiple developers and the inherent statefulness of databases that necessitates careful handling to avoid unintended data impacts. In environments like PlanetScale, a branching strategy can be employed to safely manage schema changes, allowing developers to create working branches for modifications and utilize dedicated repositories to track schema definition changes, which can then be reviewed and applied to production branches through controlled deploy requests.
Apr 05, 2023
910 words in the original blog post.