Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hivemind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
hivemind
Commits
50be8ccc
Commit
50be8ccc
authored
4 years ago
by
Mariusz Trela
Browse files
Options
Downloads
Patches
Plain Diff
An execution of `hive_accounts_info_view` view is faster
parent
07844132
No related branches found
No related tags found
5 merge requests
!456
Release candidate v1 24
,
!230
Setup monitoring with pghero
,
!138
Small typos fixed
,
!135
Enable postgres monitoring on CI server
,
!110
Teh call `get_profile` works
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hive/db/schema.py
+54
-55
54 additions, 55 deletions
hive/db/schema.py
with
54 additions
and
55 deletions
hive/db/schema.py
+
54
−
55
View file @
50be8ccc
...
@@ -567,62 +567,61 @@ def setup(db):
...
@@ -567,62 +567,61 @@ def setup(db):
CREATE OR REPLACE VIEW public.hive_accounts_info_view
CREATE OR REPLACE VIEW public.hive_accounts_info_view
AS
AS
SELECT id,
SELECT
name,
id,
display_name,
name,
about,
display_name,
reputation,
about,
created_at,
reputation,
profile_image,
created_at,
location,
profile_image,
website,
location,
cover_image,
website,
rank,
cover_image,
following,
rank,
followers,
following,
followers,
(
CASE
WHEN COALESCE( post_info.post_active_at,
'
1970-01-01 00:00:00.0
'
) > COALESCE( vote_info.vote_active_at,
'
1970-01-01 00:00:00.0
'
) THEN
(
(
CASE
CASE
WHEN post_info.post_active_at > vote_info.vote_active_at THEN
WHEN COALESCE( post_info.post_active_at,
'
1970-01-01 00:00:00.0
'
) > created_at THEN
(
COALESCE( post_info.post_active_at,
'
1970-01-01 00:00:00.0
'
)
CASE
ELSE
WHEN post_info.post_active_at > created_at THEN
created_at
post_info.post_active_at
END
ELSE
)
created_at
ELSE
END
(
)
CASE
ELSE
WHEN COALESCE( vote_info.vote_active_at,
'
1970-01-01 00:00:00.0
'
) > created_at THEN
(
COALESCE( vote_info.vote_active_at,
'
1970-01-01 00:00:00.0
'
)
CASE
ELSE
WHEN vote_info.vote_active_at > created_at THEN
created_at
vote_info.vote_active_at
END
ELSE
)
created_at
END
END
) active_at,
)
proxy,
END
proxy_weight,
) active_at,
lastread_at,
proxy,
cached_at,
proxy_weight,
raw_json,
lastread_at,
COALESCE( post_info.post_count, 0 ) post_count
cached_at,
from hive_accounts ha
raw_json,
LEFT JOIN
post_info.post_count post_count
(
FROM hive_accounts ha
select count(*) post_count, max(created_at) post_active_at, author_id
INNER JOIN
from hive_posts
(
GROUP BY author_id
select COALESCE( count(*), 0 ) post_count, COALESCE( max(hp.created_at),
'
1970-01-01 00:00:00.0
'
) post_active_at, ha.id id_internal
) post_info ON ha.id=post_info.author_id
from hive_posts hp
LEFT JOIN
RIGHT JOIN hive_accounts ha ON hp.author_id = ha.id
(
GROUP BY ha.id
select max(last_update) vote_active_at, voter_id
) post_info ON ha.id = post_info.id_internal
from hive_votes
INNER JOIN
GROUP BY voter_id
(
)vote_info ON ha.id=vote_info.voter_id
select COALESCE( max(hv.last_update),
'
1970-01-01 00:00:00.0
'
) vote_active_at, ha.id id_internal
from hive_votes hv
RIGHT JOIN hive_accounts ha ON hv.voter_id = ha.id
GROUP BY ha.id
) vote_info ON ha.id = vote_info.id_internal
"""
"""
db
.
query_no_return
(
sql
)
db
.
query_no_return
(
sql
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment