source: trunk/dnsbl/dnsbl.sql@ 69

Last change on this file since 69 was 32, checked in by Kris Deugau, 13 years ago

/trunk/dnsbl

Changeset to improve export speed on DNSBL database. By keeping
IP counts for each block, and directly tracking the parent of
each block and IP, an export taking ~90 seconds can be brought
down under 20.

  • updated initial tabledef SQL
  • Add addparents.sql SQL tabeldef and setparents.pl data update script
  • Tweak reporting of IP since it now requires the parent block(s) so the parent field can be filled in

Also add delist-ip script and Makefile

File size: 3.0 KB
Line 
1--
2-- PostgreSQL database dump
3--
4
5SET client_encoding = 'UTF8';
6SET check_function_bodies = false;
7SET client_min_messages = warning;
8
9--
10-- Name: blocks; Type: TABLE; Schema: public; Owner: dnsbl
11--
12
13CREATE TABLE blocks (
14 block cidr NOT NULL,
15 listme boolean DEFAULT false,
16 orgid integer,
17 "level" integer DEFAULT 0,
18 comments text DEFAULT ''::text,
19 parent cidr NOT NULL,
20 ipcount integer NOT NULL
21);
22
23
24--
25-- Name: iplist; Type: TABLE; Schema: public; Owner: dnsbl
26--
27
28CREATE TABLE iplist (
29 ip inet NOT NULL,
30 count integer DEFAULT 1,
31 s4list boolean DEFAULT false,
32 added timestamp with time zone DEFAULT now(),
33 parent cidr NOT NULL
34);
35
36
37--
38-- Name: orgs; Type: TABLE; Schema: public; Owner: dnsbl
39--
40
41CREATE TABLE orgs (
42 orgid serial NOT NULL,
43 listme boolean DEFAULT false,
44 orgname character varying(100) DEFAULT ''::character varying NOT NULL,
45 comments text
46);
47
48
49--
50-- Name: autolist; Type: TABLE; Schema: public; Owner: dnsbl
51--
52
53CREATE TABLE autolist (
54 masklen smallint NOT NULL,
55 ipcount bigint
56);
57
58
59--
60-- Name: misc; Type: TABLE; Schema: public; Owner: dnsbl
61--
62
63CREATE TABLE misc (
64 "key" character varying(30),
65 value character varying(255)
66);
67
68
69-- for tracking IPs that get removed from listing
70-- note we don't want a PK on IP as with iplist, since we may end up removing an IP more than once. :/
71--
72-- Name: waslisted; Type: TABLE; Schema: public; Owner: dnsbl
73--
74
75CREATE TABLE waslisted (
76 ip inet NOT NULL,
77 count integer DEFAULT 1,
78 s4list boolean DEFAULT false,
79 origadded timestamp with time zone DEFAULT now(),
80 delisted timestamp with time zone DEFAULT now()
81);
82
83
84--
85-- Name: autolist_pkey; Type: CONSTRAINT; Schema: public; Owner: dnsbl
86--
87
88ALTER TABLE ONLY autolist
89 ADD CONSTRAINT autolist_pkey PRIMARY KEY (masklen);
90
91
92--
93-- Name: blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: dnsbl
94--
95
96ALTER TABLE ONLY blocks
97 ADD CONSTRAINT blocks_pkey PRIMARY KEY (block);
98
99
100--
101-- Name: iplist_pkey; Type: CONSTRAINT; Schema: public; Owner: dnsbl
102--
103
104ALTER TABLE ONLY iplist
105 ADD CONSTRAINT iplist_pkey PRIMARY KEY (ip);
106
107
108--
109-- Name: orgs_pkey; Type: CONSTRAINT; Schema: public; Owner: dnsbl
110--
111
112ALTER TABLE ONLY orgs
113 ADD CONSTRAINT orgs_pkey PRIMARY KEY (orgid);
114
115
116--
117-- Name: blocks_parent_index; Type: INDEX; Schema: public; Owner: dnsbl
118--
119
120CREATE INDEX blocks_parent_index ON blocks USING btree (parent);
121
122
123--
124-- Name: ip_parent_index; Type: INDEX; Schema: public; Owner: dnsbl
125--
126
127CREATE INDEX ip_parent_index ON iplist USING btree (parent);
128
129
130--
131-- Name: blocks_orgid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnsbl
132--
133
134ALTER TABLE ONLY blocks
135 ADD CONSTRAINT blocks_orgid_fkey FOREIGN KEY (orgid) REFERENCES orgs(orgid);
136
137
138--
139-- Name: autolist; Type: TABLE DATA; Schema: public; Owner: dnsbl
140--
141
142COPY autolist (masklen, ipcount) FROM stdin;
14331 1
14430 1
14529 2
14628 3
14727 4
14826 5
14925 6
15024 7
15123 8
15222 10
15321 13
15420 16
15519 19
15618 22
15717 26
15816 30
15915 34
16014 38
16113 42
16212 46
16311 50
16410 54
1659 58
1668 62
1677 2147483648
1686 2147483648
1695 2147483648
1704 2147483648
1713 2147483648
1722 2147483648
1731 2147483648
1740 2147483648
175\.
Note: See TracBrowser for help on using the repository browser.