database-sharding-skill

Generate shard table names from timestamps and query across partitioned time-based tables in Go with GORM.

Updated Jan 24, 2026
One-click install
npx skills add https://github.com/Penitence1992/go-zero-backend-skills --skill database-sharding-skill
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-sharding-skill
Source: https://github.com/Penitence1992/go-zero-backend-skills/tree/main/skills/database-sharding-skill
Command: npx skills add https://github.com/Penitence1992/go-zero-backend-skills --skill database-sharding-skill

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables scalable data access by implementing time-based database sharding across partitioned tables, allowing efficient queries over large datasets.

Core Features & Use Cases

  • Time-based partitioning utilities for year- and week-based tables.
  • Shard-aware query execution that automatically resolves target tables within a time window.
  • Use Case: Generate shard table names from timestamps and perform multi-table range queries with a single API.

Quick Start

  • Define a base table name and time range, then use GetTableNameByTimestamp to determine shard tables.
  • Use EventDataSetDo to fetch results across all relevant partitions in parallel.

Frequently Asked Questions about database-sharding-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement time-based database sharding in a Go service using GORM?

Time-based database sharding in Go with GORM is implemented by generating year- or week-based table names from timestamps and executing concurrent shard queries across the relevant partitions to retrieve range query results efficiently.

What is the best way to query large datasets across time-partitioned tables in Go?

The best way to query large datasets across time-partitioned tables in Go is using a shard-aware data retrieval workflow that resolves target tables within a time window and fetches results across all relevant partitions in parallel.

Can I perform cross-table range queries over time-sharded data without manual table resolution?

Yes, you can perform cross-table range queries over time-sharded data without manual table resolution by defining a base table name and time range, then leveraging shard-aware query execution to automatically resolve and query the target partitions.

Does this time-based sharding approach support both year-based and week-based table partitioning?

Yes, this time-based sharding approach supports both year-based and week-based table partitioning by providing dedicated partitioning utilities that generate shard table names dynamically from input timestamps.

How do I determine the correct shard table names from a specific timestamp for my GORM queries?

You determine the correct shard table names from a specific timestamp by using the GetTableNameByTimestamp utility, which maps your input timestamp to the appropriate year- or week-based partitioned table name for your GORM queries.

What are the limitations of using time-based sharding for database partitioning in Go applications?

A limitation of time-based sharding for database partitioning in Go applications is that it specifically requires services using GORM for data access and is optimized primarily for range queries over time-sharded data, potentially restricting other query patterns.