# Alarme journal table partioning with postgres

**URL:** <https://forum.inductiveautomation.com/t/alarme-journal-table-partioning-with-postgres/74173>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 25, 2023, 2:27pm UTC](https://forum.inductiveautomation.com/t/alarme-journal-table-partioning-with-postgres/74173 "2023-05-25T14:27:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [May 25, 2023, 2:27pm UTC](https://forum.inductiveautomation.com/t/alarme-journal-table-partioning-with-postgres/74173/1 "2023-05-25T14:27:34Z")

</div>

I will have a some very large alarm journal tables in **PosgreSQL** (alarm\_events and alarm\_event\_data with some associated data)

I plan to use postgres db (version 15) partitioning feature.

Does anybody has some feedback on **alarms journal tables database partitionning**?

Perhaps something like that could do the job ?

**alarm\_events : PARTITION BY RANGE (eventtime)**  
**alarm\_event\_data : PARTITION BY HASH (id)**

```auto
CREATE TABLE alarm_events_xxx_x PARTITION OF alarm_events 
    FOR VALUES FROM (...) TO (...);
...

```

```auto
CREATE TABLE alarm_event_data _0 PARTITION OF alarm_event_data FOR VALUES WITH (MODULUS 10,REMAINDER 0)
CREATE TABLE alarm_event_data _0 PARTITION OF alarm_event_data FOR VALUES WITH (MODULUS 10,REMAINDER 1)
...

```

🤔 I don't known what's the best way to partition **alarm\_event\_data** table in order to keep good query response time.

> **[5.11. Table Partitioning](https://www.postgresql.org/docs/15/ddl-partitioning.html)**
>
> 5.11. Table Partitioning 5.11.1. Overview 5.11.2. Declarative Partitioning 5.11.3. Partitioning Using Inheritance 5.11.4. Partition Pruning 5.11.5. Partitioning and Constraint Exclusion 5.11.6. …
