You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-50Lines changed: 57 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,78 +12,79 @@ For proofs, see [benchmarks](/benchmarks/README.md).
12
12
13
13
## How it works
14
14
15
-
We just need to have a few tables (postgres syntax, schema managed fully by EventSQL):
16
-
15
+
We just need to have a few tables. Column names should be prefixed because some of the names are reserved keywords in some databases (Postgres syntax, schema is fully managed by EventSQL):
17
16
```sql
18
17
CREATETABLEtopic (
19
-
nameTEXTPRIMARY KEY,
20
-
partitionsSMALLINTNOT NULL,
21
-
created_atTIMESTAMPNOT NULL DEFAULT NOW()
18
+
eql_nameTEXTPRIMARY KEY,
19
+
eql_partitionsSMALLINTNOT NULL,
20
+
eql_created_atTIMESTAMPNOT NULL DEFAULT NOW()
22
21
);
23
22
24
23
CREATETABLEconsumer (
25
-
topicTEXTNOT NULL,
26
-
nameTEXTNOT NULL,
27
-
partitionSMALLINTNOT NULL,
28
-
first_event_idBIGINT,
29
-
last_event_idBIGINT,
30
-
last_consumption_atTIMESTAMP,
31
-
consumed_eventsBIGINTNOT NULL,
32
-
created_atTIMESTAMPNOT NULL DEFAULT NOW(),
33
-
PRIMARY KEY (topic, name, partition)
24
+
eql_topicTEXTNOT NULL,
25
+
eql_nameTEXTNOT NULL,
26
+
eql_partitionSMALLINTNOT NULL,
27
+
eql_first_event_idBIGINT,
28
+
eql_last_event_idBIGINT,
29
+
eql_last_consumption_atTIMESTAMP,
30
+
eql_consumed_eventsBIGINTNOT NULL,
31
+
eql_created_atTIMESTAMPNOT NULL DEFAULT NOW(),
32
+
PRIMARY KEY (eql_topic, eql_name, eql_partition)
34
33
);
35
34
36
35
CREATE TABLE {topic}_event (
37
-
idBIGSERIALPRIMARY KEY,
38
-
partitionSMALLINTNOT NULL,
39
-
keyTEXT,
40
-
valueBYTEANOT NULL,
41
-
buffered_atTIMESTAMPNOT NULL,
42
-
created_atTIMESTAMPNOT NULL DEFAULT NOW(),
43
-
metadata JSON NOT NULL
36
+
eql_idBIGSERIALPRIMARY KEY,
37
+
eql_partitionSMALLINTNOT NULL,
38
+
eql_keyTEXT,
39
+
eql_valueBYTEANOT NULL,
40
+
eql_buffered_atTIMESTAMPNOT NULL,
41
+
eql_created_atTIMESTAMPNOT NULL DEFAULT NOW(),
42
+
eql_metadata JSON NOT NULL
44
43
);
45
44
46
45
-- Same schema as event, just not partitioned (by topic). --
47
46
-- It is used to handle eventual consistency of auto increment; --
48
-
-- there is no guarantee that record of id 2 is visible after id 1 record. --
47
+
-- there is no guarantee that record of id 2 is visible only after id 1 record. --
49
48
-- Events are first inserted to the event_buffer; --
50
-
-- they are then moved to the {topic}_event table in bulk, by a single, serialized writer (per topic); --
51
-
--because there is only one writer, it fixes eventual consistency issue --
49
+
-- they are then moved to the {topic}_event table in bulk, by a single, serialized writer (per topic). --
50
+
--Because there is only one writer, it fixes eventual consistency issue --
0 commit comments