Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
c59487cf
Commit
c59487cf
authored
Sep 20, 2006
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bogus markup.
parent
f2aad314
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
30 deletions
+31
-30
doc/src/sgml/ddl.sgml
doc/src/sgml/ddl.sgml
+31
-30
No files found.
doc/src/sgml/ddl.sgml
View file @
c59487cf
<
!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.6
2 2006/09/20 01:20:38 neilc
Exp $ -->
<
!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.6
3 2006/09/20 21:30:20 tgl
Exp $ -->
<
chapter
id
=
"ddl"
>
<
title
>
Data
Definition
</
title
>
...
...
@@ -2478,20 +2478,20 @@ CREATE TABLE measurement_y2006m01 ( ) INHERITS (measurement);
<programlisting>
CREATE TABLE measurement_y2004m02 (
CHECK ( logdate
>= DATE '
2004
-
02
-
01
' AND logdate <
DATE '
2004
-
03
-
01
' )
CHECK ( logdate
>= DATE '
2004
-
02
-
01
' AND logdate <
DATE '
2004
-
03
-
01
' )
) INHERITS (measurement);
CREATE TABLE measurement_y2004m03 (
CHECK ( logdate
>= DATE '
2004
-
03
-
01
' AND logdate <
DATE '
2004
-
04
-
01
' )
CHECK ( logdate
>= DATE '
2004
-
03
-
01
' AND logdate <
DATE '
2004
-
04
-
01
' )
) INHERITS (measurement);
...
CREATE TABLE measurement_y2005m11 (
CHECK ( logdate
>= DATE '
2005
-
11
-
01
' AND logdate <
DATE '
2005
-
12
-
01
' )
CHECK ( logdate
>= DATE '
2005
-
11
-
01
' AND logdate <
DATE '
2005
-
12
-
01
' )
) INHERITS (measurement);
CREATE TABLE measurement_y2005m12 (
CHECK ( logdate
>= DATE '
2005
-
12
-
01
' AND logdate <
DATE '
2006
-
01
-
01
' )
CHECK ( logdate
>= DATE '
2005
-
12
-
01
' AND logdate <
DATE '
2006
-
01
-
01
' )
) INHERITS (measurement);
CREATE TABLE measurement_y2006m01 (
CHECK ( logdate
>= DATE '
2006
-
01
-
01
' AND logdate <
DATE '
2006
-
02
-
01
' )
CHECK ( logdate
>= DATE '
2006
-
01
-
01
' AND logdate <
DATE '
2006
-
02
-
01
' )
) INHERITS (measurement);
</programlisting>
</para>
...
...
@@ -2538,7 +2538,7 @@ DO INSTEAD
<programlisting>
CREATE RULE measurement_insert_y2004m02 AS
ON INSERT TO measurement WHERE
( logdate
>= DATE '
2004
-
02
-
01
' AND logdate <
DATE '
2004
-
03
-
01
' )
( logdate
>= DATE '
2004
-
02
-
01
' AND logdate <
DATE '
2004
-
03
-
01
' )
DO INSTEAD
INSERT INTO measurement_y2004m02 VALUES ( NEW.city_id,
NEW.logdate,
...
...
@@ -2547,7 +2547,7 @@ DO INSTEAD
...
CREATE RULE measurement_insert_y2005m12 AS
ON INSERT TO measurement WHERE
( logdate
>= DATE '
2005
-
12
-
01
' AND logdate <
DATE '
2006
-
01
-
01
' )
( logdate
>= DATE '
2005
-
12
-
01
' AND logdate <
DATE '
2006
-
01
-
01
' )
DO INSTEAD
INSERT INTO measurement_y2005m12 VALUES ( NEW.city_id,
NEW.logdate,
...
...
@@ -2555,7 +2555,7 @@ DO INSTEAD
NEW.unitsales );
CREATE RULE measurement_insert_y2006m01 AS
ON INSERT TO measurement WHERE
( logdate
>= DATE '
2006
-
01
-
01
' AND logdate <
DATE '
2006
-
02
-
01
' )
( logdate
>= DATE '
2006
-
01
-
01
' AND logdate <
DATE '
2006
-
02
-
01
' )
DO INSTEAD
INSERT INTO measurement_y2006m01 VALUES ( NEW.city_id,
NEW.logdate,
...
...
@@ -2577,6 +2577,7 @@ DO INSTEAD
creating a new partition each month, so it may be wise to write a
script that generates the required DDL automatically.
</para>
</sect2>
<sect2 id="ddl-partitioning-managing-partitions">
<title>Managing Partitions</title>
...
...
@@ -2624,7 +2625,7 @@ ALTER TABLE measurement_y2003mm02 NO INHERIT measurement;
<
programlisting
>
CREATE
TABLE
measurement_y2006m02
(
CHECK
(
logdate
>=
DATE
'2006-02-01'
AND
logdate
<
DATE
'2006-03-01'
)
CHECK
(
logdate
&
gt
;=
DATE
'2006-02-01'
AND
logdate
&
lt
;
DATE
'2006-03-01'
)
)
INHERITS
(
measurement
);
</
programlisting
>
...
...
@@ -2637,7 +2638,7 @@ CREATE TABLE measurement_y2006m02 (
CREATE
TABLE
measurement_y2006m02
(
LIKE
measurement
INCLUDING
DEFAULTS
INCLUDING
CONSTRAINTS
);
\
COPY
measurement_y2006m02
FROM
'measurement_y2006m02'
UPDATE
...
;
ALTER
TABLE
measurement_y2006m02
ADD
CONSTRAINT
y2006m02
CHECK
(
logdate
>=
DATE
'2006-02-01'
AND
logdate
<
DATE
'2006-03-01'
);
ALTER
TABLE
measurement_y2006m02
ADD
CONSTRAINT
y2006m02
CHECK
(
logdate
&
gt
;=
DATE
'2006-02-01'
AND
logdate
&
lt
;
DATE
'2006-03-01'
);
ALTER
TABLE
measurement_y2006m02
INHERIT
measurement
;
</
programlisting
>
</
para
>
...
...
@@ -2717,7 +2718,7 @@ UNION ALL SELECT * FROM measurement_y2006m01;
<
programlisting
>
SET
constraint_exclusion
=
on
;
SELECT
count
(*)
FROM
measurement
WHERE
logdate
>
=
DATE
'2006-01-01'
;
SELECT
count
(*)
FROM
measurement
WHERE
logdate
&
gt
;
=
DATE
'2006-01-01'
;
</
programlisting
>
Without
constraint
exclusion
,
the
above
query
would
scan
each
of
...
...
@@ -2736,23 +2737,23 @@ SELECT count(*) FROM measurement WHERE logdate >= DATE '2006-01-01';
<programlisting>
SET constraint_exclusion = off;
EXPLAIN SELECT count(*) FROM measurement WHERE logdate
>
= DATE '
2006
-
01
-
01
';
EXPLAIN SELECT count(*) FROM measurement WHERE logdate
>
= DATE '
2006
-
01
-
01
';
QUERY PLAN
-----------------------------------------------------------------------------------------------
Aggregate (cost=158.66..158.68 rows=1 width=0)
-
>
Append (cost=0.00..151.88 rows=2715 width=0)
-
>
Seq Scan on measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2004m02 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2004m03 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Append (cost=0.00..151.88 rows=2715 width=0)
-
>
Seq Scan on measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2004m02 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2004m03 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
...
-
>
Seq Scan on measurement_y2005m12 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2006m01 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2005m12 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2006m01 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
</programlisting>
Some or all of the partitions might use index scans instead of
...
...
@@ -2763,15 +2764,15 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate >= DATE '2006-01-01';
<programlisting>
SET constraint_exclusion = on;
EXPLAIN SELECT count(*) FROM measurement WHERE logdate
>
= DATE '
2006
-
01
-
01
';
EXPLAIN SELECT count(*) FROM measurement WHERE logdate
>
= DATE '
2006
-
01
-
01
';
QUERY PLAN
-----------------------------------------------------------------------------------------------
Aggregate (cost=63.47..63.48 rows=1 width=0)
-
>
Append (cost=0.00..60.75 rows=1086 width=0)
-
>
Seq Scan on measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2006m01 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Append (cost=0.00..60.75 rows=1086 width=0)
-
>
Seq Scan on measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
-
>
Seq Scan on measurement_y2006m01 measurement (cost=0.00..30.38 rows=543 width=0)
Filter: (logdate
>
= '
2006
-
01
-
01
'::date)
</programlisting>
</para>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment