Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminar duplicados na origem, e indexar afa_id #33

Open
ppKrauss opened this issue Dec 10, 2023 · 0 comments
Open

Eliminar duplicados na origem, e indexar afa_id #33

ppKrauss opened this issue Dec 10, 2023 · 0 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Comments

@ppKrauss
Copy link
Contributor

Importante resgatar os itens descartados em outra tabela. Usando

create table optim.consolidated_data_dups AS 
 SELECT rank() OVER (PARTITION BY afa_id ORDER BY house_number desc,geom) as id_rank, *
  from optim.consolidated_data
  where afa_id IN (select afa_id from optim.consolidated_data group by afa_id having count(*)>1)
; --    586

Para remover e inserir, sem risco, usar:

DELETE FROM optim.consolidated_data
  WHERE afa_id IN (select distinct afa_id from optim.consolidated_data_dups)
;
INSERT INTO optim.consolidated_data
  SELECT id,afa_id,via_type, via_name, house_number, postcode, geom_frontparcel, score, geom
  FROM optim.consolidated_data_dups  WHERE id_rank=1
;

Indexar afa_id como PK

ALTER TABLE optim.consolidated_data ADD PRIMARY KEY ( afa_id );

Comparar com indexão da geom, ver https://github.com/osm-codes/GGeohash/blob/main/src/step80benchmark-p1.sql

@ppKrauss ppKrauss added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Dec 10, 2023
0e1 added a commit to digital-guard/preserv that referenced this issue Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants