Project

General

Profile

« Previous | Next » 

Revision 13928

bugfix: schemas/public_.sql: 2014-6-4.Iara_Lacher.reserve_prioritization: fixed slowdown in materializing the view, which was caused by source__observation_type(), by replacing this with a LEFT JOIN as was done for is_threatened_iucn

View differences:

trunk/schemas/vegbien.my.sql
3859 3859

  
3860 3860

  
3861 3861
--
3862
-- Name: source; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3863
--
3864

  
3865
CREATE TABLE source (
3866
    source_id int(11) NOT NULL,
3867
    matched_source_id int(11),
3868
    parent_id int(11),
3869
    shortname varchar(255) NOT NULL,
3870
    citation varchar(255),
3871
    sourcetype varchar(255),
3872
    accesslevel varchar(255),
3873
    accessconditions varchar(255),
3874
    observationtype varchar(255),
3875
    title varchar(255),
3876
    titlesuperior varchar(255),
3877
    volume varchar(255),
3878
    issue varchar(255),
3879
    pagerange varchar(255),
3880
    totalpages int(11),
3881
    publisher varchar(255),
3882
    publicationplace varchar(255),
3883
    isbn varchar(255),
3884
    edition varchar(255),
3885
    numberofvolumes int(11),
3886
    chapternumber int(11),
3887
    reportnumber int(11),
3888
    communicationtype varchar(255),
3889
    degree varchar(255),
3890
    url varchar(255),
3891
    doi varchar(255),
3892
    additionalinfo varchar(255),
3893
    pubdate date,
3894
    accessdate date,
3895
    conferencedate date,
3896
    datecreated date  NOT NULL,
3897
    createdby varchar(255),
3898
    datelastmodified date  NOT NULL,
3899
    lastmodifiedby varchar(255),
3900
    import_revision varchar(255)
3901
);
3902

  
3903

  
3904
--
3862 3905
-- Name: 2014-6-4.Iara_Lacher.reserve_prioritization; Type: VIEW; Schema: public; Owner: -
3863 3906
--
3864 3907

  
......
5206 5249

  
5207 5250

  
5208 5251
--
5209
-- Name: source; Type: TABLE; Schema: public; Owner: -; Tablespace: 
5210
--
5211

  
5212
CREATE TABLE source (
5213
    source_id int(11) NOT NULL,
5214
    matched_source_id int(11),
5215
    parent_id int(11),
5216
    shortname varchar(255) NOT NULL,
5217
    citation varchar(255),
5218
    sourcetype varchar(255),
5219
    accesslevel varchar(255),
5220
    accessconditions varchar(255),
5221
    observationtype varchar(255),
5222
    title varchar(255),
5223
    titlesuperior varchar(255),
5224
    volume varchar(255),
5225
    issue varchar(255),
5226
    pagerange varchar(255),
5227
    totalpages int(11),
5228
    publisher varchar(255),
5229
    publicationplace varchar(255),
5230
    isbn varchar(255),
5231
    edition varchar(255),
5232
    numberofvolumes int(11),
5233
    chapternumber int(11),
5234
    reportnumber int(11),
5235
    communicationtype varchar(255),
5236
    degree varchar(255),
5237
    url varchar(255),
5238
    doi varchar(255),
5239
    additionalinfo varchar(255),
5240
    pubdate date,
5241
    accessdate date,
5242
    conferencedate date,
5243
    datecreated date  NOT NULL,
5244
    createdby varchar(255),
5245
    datelastmodified date  NOT NULL,
5246
    lastmodifiedby varchar(255),
5247
    import_revision varchar(255)
5248
);
5249

  
5250

  
5251
--
5252 5252
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace: 
5253 5253
--
5254 5254

  
......
14467 14467

  
14468 14468

  
14469 14469
--
14470
-- Name: source; Type: ACL; Schema: public; Owner: -
14471
--
14472

  
14473

  
14474

  
14475

  
14476

  
14477

  
14478

  
14479

  
14480
--
14470 14481
-- Name: 2014-6-4.Iara_Lacher.reserve_prioritization; Type: ACL; Schema: public; Owner: -
14471 14482
--
14472 14483

  
......
14608 14619

  
14609 14620

  
14610 14621
--
14611
-- Name: source; Type: ACL; Schema: public; Owner: -
14612
--
14613

  
14614

  
14615

  
14616

  
14617

  
14618

  
14619

  
14620

  
14621
--
14622 14622
-- Name: stratum; Type: ACL; Schema: public; Owner: -
14623 14623
--
14624 14624

  
trunk/schemas/public_.sql
6156 6156

  
6157 6157

  
6158 6158
--
6159
-- Name: source; Type: TABLE; Schema: public; Owner: -; Tablespace: 
6160
--
6161

  
6162
CREATE TABLE source (
6163
    source_id integer NOT NULL,
6164
    matched_source_id integer,
6165
    parent_id integer,
6166
    shortname text NOT NULL,
6167
    citation text,
6168
    sourcetype sourcetype,
6169
    accesslevel accesslevel,
6170
    accessconditions text,
6171
    observationtype observationtype,
6172
    title text,
6173
    titlesuperior text,
6174
    volume text,
6175
    issue text,
6176
    pagerange text,
6177
    totalpages integer,
6178
    publisher text,
6179
    publicationplace text,
6180
    isbn text,
6181
    edition text,
6182
    numberofvolumes integer,
6183
    chapternumber integer,
6184
    reportnumber integer,
6185
    communicationtype text,
6186
    degree text,
6187
    url text,
6188
    doi text,
6189
    additionalinfo text,
6190
    pubdate date,
6191
    accessdate date,
6192
    conferencedate date,
6193
    datecreated date DEFAULT now() NOT NULL,
6194
    createdby text,
6195
    datelastmodified date DEFAULT now() NOT NULL,
6196
    lastmodifiedby text,
6197
    import_revision text
6198
);
6199

  
6200

  
6201
--
6159 6202
-- Name: 2014-6-4.Iara_Lacher.reserve_prioritization; Type: VIEW; Schema: public; Owner: -
6160 6203
--
6161 6204

  
......
6164 6207
    analytical_stem."decimalLatitude__@DwC__@vegpath.org" AS "decimalLatitude",
6165 6208
    analytical_stem."decimalLongitude__@DwC__@vegpath.org" AS "decimalLongitude",
6166 6209
    analytical_stem."(-Earliest-)DateCollected__-2007-04-17__@DwC__.hist@vegpath.org" AS "dateCollected",
6167
    source__observation_type(analytical_stem."datasource__@Brad__.identifier_examples@vegpath.org") AS collection_type,
6210
    source.observationtype AS collection_type,
6168 6211
    COALESCE(analytical_stem."[custodial_]institutionCode[s]__@DwC__@vegpath.org", analytical_stem."datasource__@Brad__.identifier_examples@vegpath.org") AS orig_datasource,
6169 6212
    analytical_stem.scrubbed_family AS accepted_family,
6170 6213
    analytical_stem.scrubbed_genus AS accepted_genus,
......
6174 6217
    analytical_stem."stemHeight[_m]__@VegBank__.stemCount@vegpath.org" AS height_m,
6175 6218
    analytical_stem."[growth_form=]habit__@SALVIAS__.Plot_data@vegpath.org" AS lifeform,
6176 6219
    (iucn_red_list.accepted_family IS NOT NULL) AS is_threatened_iucn
6177
   FROM (analytical_stem
6220
   FROM ((analytical_stem
6221
   LEFT JOIN source ON ((source.shortname = analytical_stem."datasource__@Brad__.identifier_examples@vegpath.org")))
6178 6222
   LEFT JOIN iucn_red_list ON (((iucn_red_list.accepted_family = analytical_stem.scrubbed_family) AND (iucn_red_list.accepted_species_binomial = analytical_stem.scrubbed_species_binomial))))
6179 6223
  WHERE (((((COALESCE((analytical_stem.geovalid_bien)::boolean, true) AND (NOT COALESCE((analytical_stem.cultivated_bien)::boolean, false))) AND (analytical_stem."decimalLatitude__@DwC__@vegpath.org" IS NOT NULL)) AND (analytical_stem."decimalLongitude__@DwC__@vegpath.org" IS NOT NULL)) AND in_south_america(analytical_stem."decimalLatitude__@DwC__@vegpath.org", analytical_stem."decimalLongitude__@DwC__@vegpath.org")) AND COALESCE((analytical_stem."taxonomicStatus__@DwC__@vegpath.org" = 'accepted'::text), false));
6180 6224

  
......
7752 7796

  
7753 7797

  
7754 7798
--
7755
-- Name: source; Type: TABLE; Schema: public; Owner: -; Tablespace: 
7756
--
7757

  
7758
CREATE TABLE source (
7759
    source_id integer NOT NULL,
7760
    matched_source_id integer,
7761
    parent_id integer,
7762
    shortname text NOT NULL,
7763
    citation text,
7764
    sourcetype sourcetype,
7765
    accesslevel accesslevel,
7766
    accessconditions text,
7767
    observationtype observationtype,
7768
    title text,
7769
    titlesuperior text,
7770
    volume text,
7771
    issue text,
7772
    pagerange text,
7773
    totalpages integer,
7774
    publisher text,
7775
    publicationplace text,
7776
    isbn text,
7777
    edition text,
7778
    numberofvolumes integer,
7779
    chapternumber integer,
7780
    reportnumber integer,
7781
    communicationtype text,
7782
    degree text,
7783
    url text,
7784
    doi text,
7785
    additionalinfo text,
7786
    pubdate date,
7787
    accessdate date,
7788
    conferencedate date,
7789
    datecreated date DEFAULT now() NOT NULL,
7790
    createdby text,
7791
    datelastmodified date DEFAULT now() NOT NULL,
7792
    lastmodifiedby text,
7793
    import_revision text
7794
);
7795

  
7796

  
7797
--
7798 7799
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace: 
7799 7800
--
7800 7801

  
......
18256 18257

  
18257 18258

  
18258 18259
--
18260
-- Name: source; Type: ACL; Schema: public; Owner: -
18261
--
18262

  
18263
REVOKE ALL ON TABLE source FROM PUBLIC;
18264
REVOKE ALL ON TABLE source FROM bien;
18265
GRANT ALL ON TABLE source TO bien;
18266
GRANT SELECT ON TABLE source TO bien_read;
18267
GRANT SELECT ON TABLE source TO public_;
18268

  
18269

  
18270
--
18259 18271
-- Name: 2014-6-4.Iara_Lacher.reserve_prioritization; Type: ACL; Schema: public; Owner: -
18260 18272
--
18261 18273

  
......
18397 18409

  
18398 18410

  
18399 18411
--
18400
-- Name: source; Type: ACL; Schema: public; Owner: -
18401
--
18402

  
18403
REVOKE ALL ON TABLE source FROM PUBLIC;
18404
REVOKE ALL ON TABLE source FROM bien;
18405
GRANT ALL ON TABLE source TO bien;
18406
GRANT SELECT ON TABLE source TO bien_read;
18407
GRANT SELECT ON TABLE source TO public_;
18408

  
18409

  
18410
--
18411 18412
-- Name: stratum; Type: ACL; Schema: public; Owner: -
18412 18413
--
18413 18414

  
trunk/schemas/vegbien.sql
6156 6156

  
6157 6157

  
6158 6158
--
6159
-- Name: source; Type: TABLE; Schema: public; Owner: -; Tablespace: 
6160
--
6161

  
6162
CREATE TABLE source (
6163
    source_id integer NOT NULL,
6164
    matched_source_id integer,
6165
    parent_id integer,
6166
    shortname text NOT NULL,
6167
    citation text,
6168
    sourcetype sourcetype,
6169
    accesslevel accesslevel,
6170
    accessconditions text,
6171
    observationtype observationtype,
6172
    title text,
6173
    titlesuperior text,
6174
    volume text,
6175
    issue text,
6176
    pagerange text,
6177
    totalpages integer,
6178
    publisher text,
6179
    publicationplace text,
6180
    isbn text,
6181
    edition text,
6182
    numberofvolumes integer,
6183
    chapternumber integer,
6184
    reportnumber integer,
6185
    communicationtype text,
6186
    degree text,
6187
    url text,
6188
    doi text,
6189
    additionalinfo text,
6190
    pubdate date,
6191
    accessdate date,
6192
    conferencedate date,
6193
    datecreated date DEFAULT now() NOT NULL,
6194
    createdby text,
6195
    datelastmodified date DEFAULT now() NOT NULL,
6196
    lastmodifiedby text,
6197
    import_revision text
6198
);
6199

  
6200

  
6201
--
6159 6202
-- Name: 2014-6-4.Iara_Lacher.reserve_prioritization; Type: VIEW; Schema: public; Owner: -
6160 6203
--
6161 6204

  
......
6164 6207
    analytical_stem."decimalLatitude__@DwC__@vegpath.org" AS "decimalLatitude",
6165 6208
    analytical_stem."decimalLongitude__@DwC__@vegpath.org" AS "decimalLongitude",
6166 6209
    analytical_stem."(-Earliest-)DateCollected__-2007-04-17__@DwC__.hist@vegpath.org" AS "dateCollected",
6167
    source__observation_type(analytical_stem."datasource__@Brad__.identifier_examples@vegpath.org") AS collection_type,
6210
    source.observationtype AS collection_type,
6168 6211
    COALESCE(analytical_stem."[custodial_]institutionCode[s]__@DwC__@vegpath.org", analytical_stem."datasource__@Brad__.identifier_examples@vegpath.org") AS orig_datasource,
6169 6212
    analytical_stem.scrubbed_family AS accepted_family,
6170 6213
    analytical_stem.scrubbed_genus AS accepted_genus,
......
6174 6217
    analytical_stem."stemHeight[_m]__@VegBank__.stemCount@vegpath.org" AS height_m,
6175 6218
    analytical_stem."[growth_form=]habit__@SALVIAS__.Plot_data@vegpath.org" AS lifeform,
6176 6219
    (iucn_red_list.accepted_family IS NOT NULL) AS is_threatened_iucn
6177
   FROM (analytical_stem
6220
   FROM ((analytical_stem
6221
   LEFT JOIN source ON ((source.shortname = analytical_stem."datasource__@Brad__.identifier_examples@vegpath.org")))
6178 6222
   LEFT JOIN iucn_red_list ON (((iucn_red_list.accepted_family = analytical_stem.scrubbed_family) AND (iucn_red_list.accepted_species_binomial = analytical_stem.scrubbed_species_binomial))))
6179 6223
  WHERE (((((COALESCE((analytical_stem.geovalid_bien)::boolean, true) AND (NOT COALESCE((analytical_stem.cultivated_bien)::boolean, false))) AND (analytical_stem."decimalLatitude__@DwC__@vegpath.org" IS NOT NULL)) AND (analytical_stem."decimalLongitude__@DwC__@vegpath.org" IS NOT NULL)) AND in_south_america(analytical_stem."decimalLatitude__@DwC__@vegpath.org", analytical_stem."decimalLongitude__@DwC__@vegpath.org")) AND COALESCE((analytical_stem."taxonomicStatus__@DwC__@vegpath.org" = 'accepted'::text), false));
6180 6224

  
......
7752 7796

  
7753 7797

  
7754 7798
--
7755
-- Name: source; Type: TABLE; Schema: public; Owner: -; Tablespace: 
7756
--
7757

  
7758
CREATE TABLE source (
7759
    source_id integer NOT NULL,
7760
    matched_source_id integer,
7761
    parent_id integer,
7762
    shortname text NOT NULL,
7763
    citation text,
7764
    sourcetype sourcetype,
7765
    accesslevel accesslevel,
7766
    accessconditions text,
7767
    observationtype observationtype,
7768
    title text,
7769
    titlesuperior text,
7770
    volume text,
7771
    issue text,
7772
    pagerange text,
7773
    totalpages integer,
7774
    publisher text,
7775
    publicationplace text,
7776
    isbn text,
7777
    edition text,
7778
    numberofvolumes integer,
7779
    chapternumber integer,
7780
    reportnumber integer,
7781
    communicationtype text,
7782
    degree text,
7783
    url text,
7784
    doi text,
7785
    additionalinfo text,
7786
    pubdate date,
7787
    accessdate date,
7788
    conferencedate date,
7789
    datecreated date DEFAULT now() NOT NULL,
7790
    createdby text,
7791
    datelastmodified date DEFAULT now() NOT NULL,
7792
    lastmodifiedby text,
7793
    import_revision text
7794
);
7795

  
7796

  
7797
--
7798 7799
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace: 
7799 7800
--
7800 7801

  
......
18256 18257

  
18257 18258

  
18258 18259
--
18260
-- Name: source; Type: ACL; Schema: public; Owner: -
18261
--
18262

  
18263
REVOKE ALL ON TABLE source FROM PUBLIC;
18264
REVOKE ALL ON TABLE source FROM bien;
18265
GRANT ALL ON TABLE source TO bien;
18266
GRANT SELECT ON TABLE source TO bien_read;
18267
GRANT SELECT ON TABLE source TO public_;
18268

  
18269

  
18270
--
18259 18271
-- Name: 2014-6-4.Iara_Lacher.reserve_prioritization; Type: ACL; Schema: public; Owner: -
18260 18272
--
18261 18273

  
......
18397 18409

  
18398 18410

  
18399 18411
--
18400
-- Name: source; Type: ACL; Schema: public; Owner: -
18401
--
18402

  
18403
REVOKE ALL ON TABLE source FROM PUBLIC;
18404
REVOKE ALL ON TABLE source FROM bien;
18405
GRANT ALL ON TABLE source TO bien;
18406
GRANT SELECT ON TABLE source TO bien_read;
18407
GRANT SELECT ON TABLE source TO public_;
18408

  
18409

  
18410
--
18411 18412
-- Name: stratum; Type: ACL; Schema: public; Owner: -
18412 18413
--
18413 18414

  

Also available in: Unified diff