Metadata-Version: 2.1
Name: psql-stat-optimizer
Version: 0.0.45
Summary: Postgresql Set Statistics
Home-page: https://github.com/miare-ir/psql-optimizer
Author: Amir Alaghmandan
Author-email: amir.amotlagh@gmail.com
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.0
Classifier: Framework :: Django :: 3.1
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django-tqdm (==1.3.1)
Requires-Dist: Django (>=2.2)

# query-plan-optimizer
[![](https://img.shields.io/pypi/v/psql-stat-optimizer)](https://pypi.org/project/psql-stat-optimizer/) [![](https://img.shields.io/pypi/djversions/psql-stat-optimizer)](https://pypi.org/project/psql-stat-optimizer/)

Postgresql Statistics are vital for a good query plan. This library finds tables with large number of live tuples and tries to find related models with foreign key to the model and sets statistics for the field on destination model.

## Installation
```bash
$ pip install psql-stat-optimizer
```
add `psql_optimizer` to your `INSTALLED_APPS`

## usage:
### Using full optimize command:

```bash
$ ./manage.py optimize_statistics
```

#### Valid Parameters:
- set_all: if passed as `True` it sets for all founded models automatically
- analyze_all: if passed as `True` it analyzes all models after their statistics is changed
- live_tup_count: the minimum number of n_live_tup to consider as a big table. *default is 100000*
- statistics: the statistics value you want to set to. *default is 10000*

### Using statistics command:

```bash
$ ./manage.py set_statistics
```

#### Parameters:
- table: the target table name
- column: the target column
- statistics: the target statistics

## TODO:
- remove time.sleep which is used for printing
- add command for analyze a table manually

