Download the PHP package brokenice/laravel-pgsql-partition without Composer

On this page you can find all versions of the php package brokenice/laravel-pgsql-partition. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-pgsql-partition

Laravel PostgreSQL Partition

Laravel-pgsql-partition is a useful Laravel package to easily work with PostgreSQL Table Partitioning. Partitioning requires PostgreSQL version >= 10.0.

Installation

Add the package using composer:

For Laravel versions before 5.5 or if not using auto-discovery, register the service provider in config/app.php:

Quickstart

Create a partitioned table migration

From the command line:

Then edit the migration you just created:

Run the migration:

Partition Types Support

PostgreSQL supports these partitioning methods:

Type Description
RANGE Partition based on a range of values
LIST Partition based on a list of discrete values
HASH Partition based on hash of the partition key

Usage Examples

Partition by RANGE

This type of partitioning assigns rows to partitions based on column values falling within a given range.

Partition by LIST

Similar to partitioning by RANGE, except that the partition is selected based on columns matching one of a set of discrete values.

Partition by HASH

With this type of partitioning, a partition is selected based on the hash of the partition key.

Partition by YEARS

Convenience method to partition a table by year ranges:

Partition by YEARS AND MONTHS

Create partitions for each month within a year range:

Partition Maintenance

Detach a Partition

Detaching a partition keeps the data but removes it from the partitioned table:

Attach a Partition

Attach an existing table as a partition:

Drop a Partition

Permanently delete a partition and its data:

Truncate a Partition

Remove all data from a partition:

Vacuum (Optimize)

Reclaim storage and update statistics:

Analyze

Update query planner statistics:

Reindex

Rebuild indexes on a partition:

Querying Partitions with Eloquent

Create a Model

Query a Specific Partition

In PostgreSQL, partitions are separate tables, so you can query them directly:

Query Multiple Partitions

Using MultipleSchemaModel

For multi-schema support:

Artisan Commands

This package provides a set of artisan commands for partition management:

Available Actions

Action Description
list List all partitions for a table
create Create partitions on an existing partitioned table
detach Detach a partition (keeps data)
attach Attach a table as a partition
drop Drop a partition (deletes data)
truncate Truncate partition data
vacuum Run VACUUM on partitions
analyze Run ANALYZE on partitions
reindex Run REINDEX on partitions

Examples

Options

Option Description
--schema PostgreSQL schema (default: public)
--table Parent table name
--method Partition method: RANGE, LIST, HASH, YEAR, MONTH, YEAR_MONTH
--column Column to partition by
--number Number of partitions (for HASH)
--partitions Partition names (comma-separated)
--excludeDefault Don't create a default partition
--from Start value for RANGE partition
--to End value for RANGE partition
--full Use VACUUM FULL

PostgreSQL vs MySQL Partitioning

Key differences from the MySQL version of this package:

Feature MySQL PostgreSQL
Partition creation ALTER TABLE on existing At CREATE TABLE or separate CREATE TABLE ... PARTITION OF
Future values MAXVALUE DEFAULT partition
Subpartitions Native support Partition of partition
KEY partitioning Supported Use HASH instead
Maintenance OPTIMIZE, REPAIR, REBUILD VACUUM, ANALYZE, REINDEX

Important Notes

  1. PostgreSQL 10+ Required: Native declarative partitioning requires PostgreSQL 10 or higher.

  2. Primary Keys: In PostgreSQL, the partition key must be included in any primary key or unique constraint.

  3. Auto-increment: Use BIGSERIAL for auto-increment columns, but include the partition key in the primary key:

  4. Indexes: Each partition maintains its own indexes. Create indexes on the parent table and they'll be automatically created on partitions.

  5. Default Partition: Always consider adding a default partition to catch rows that don't match any other partition.

Tests

For integration tests (requires PostgreSQL):

Contributing

Recommendations and pull requests are most welcome! Pull requests with tests are the best!

Credits & License

laravel-pgsql-partition is owned and maintained by Luca Becchetti

As open source creation any help is welcome!

The code of this library is licensed under MIT License; you can use it in commercial products without any limitation.

The only requirement is to add a line in your Credits/About section with the text below:


All versions of laravel-pgsql-partition with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-pdo Version *
ext-json Version *
illuminate/database Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
ext-mbstring Version *
ext-pdo_pgsql Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package brokenice/laravel-pgsql-partition contains the following files

Loading the files please wait ...