8000 perf: Amélioration de la performance de la requête dans getLasDiscoveries by andriacap · Pull Request #455 · PnX-SI/GeoNature-atlas · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

perf: Amélioration de la performance de la requête dans getLasDiscoveries #455

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions atlas/modeles/repositories/vmObservationsRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,16 @@ def genericStatMedias(connection, tab):

def getLastDiscoveries(connection):
sql="""
SELECT date(min(dateobs)), vo.cd_ref, vt.lb_nom, vt.nom_vern, m.id_media, m.chemin, m.url, vt.group2_inpn
FROM atlas.vm_observations vo
JOIN atlas.vm_taxref vt ON vo.cd_ref = vt.cd_nom
LEFT JOIN atlas.vm_medias m ON m.cd_ref=vo.cd_ref and m.id_type = :thisidtype
with t as (SELECT date(min(vo.dateobs)) date, vo.cd_ref
FROM atlas.vm_observations vo
GROUP BY vo.cd_ref
ORDER BY date desc)
select t.*, vt.lb_nom, vt.nom_vern, m.id_media, m.chemin, m.url, vt.group2_inpn
from t
JOIN atlas.vm_taxref vt ON t.cd_ref = vt.cd_nom
LEFT JOIN atlas.vm_medias m ON m.cd_ref=t.cd_ref and m.id_type = :thisidtype
WHERE id_rang='ES'
GROUP BY vo.cd_ref, vt.lb_nom, vt.nom_vern, m.id_media, m.chemin, m.url, vt.group2_inpn
ORDER BY min(dateobs) DESC
order by t.date desc
LIMIT 6
"""
req = connection.execute(text(sql), thisidtype=current_app.config["ATTR_MAIN_PHOTO"])
Expand Down
0