Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Julien Moutinho
haskell-gargantext
Commits
786a2d44
Verified
Commit
786a2d44
authored
Jun 02, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] attempt to fix query performance
parent
f71c1fff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
NgramsByContext.hs
src/Gargantext/Database/Action/Metrics/NgramsByContext.hs
+26
-10
No files found.
src/Gargantext/Database/Action/Metrics/NgramsByContext.hs
View file @
786a2d44
...
...
@@ -130,23 +130,39 @@ getOccByNgramsOnlyFast cId lId nt = do
query
::
DPS
.
Query
query
=
[
sql
|
WITH node_context_ids AS
(
select context_id, ngrams_id
(
SELECT context_id, ngrams_id, terms
FROM context_node_ngrams_view
JOIN ngrams ON context_node_ngrams_view.ngrams_id = ngrams.id
WHERE node_id = ?
), ns AS
(
select
ngrams_id FROM node_stories
(
SELECT
ngrams_id FROM node_stories
WHERE node_id = ? AND ngrams_type_id = ?
)
SELECT ng.terms,
ARRAY ( SELECT DISTINCT context_id
FROM node_context_ids
WHERE ns.ngrams_id = node_context_ids.ngrams_id
)
AS context_ids
FROM ngrams ng
JOIN ns ON ng.id = ns.ngrams_id
SELECT terms, array_agg(DISTINCT context_id)
FROM ns
JOIN node_context_ids ON ns.ngrams_id = node_context_ids.ngrams_id
GROUP BY terms
|]
-- query = [sql|
-- WITH node_context_ids AS
-- (select context_id, ngrams_id
-- FROM context_node_ngrams_view
-- WHERE node_id = ?
-- ), ns AS
-- (select ngrams_id FROM node_stories
-- WHERE node_id = ? AND ngrams_type_id = ?
-- )
-- SELECT ng.terms,
-- ARRAY ( SELECT DISTINCT context_id
-- FROM node_context_ids
-- WHERE ns.ngrams_id = node_context_ids.ngrams_id
-- )
-- AS context_ids
-- FROM ngrams ng
-- JOIN ns ON ng.id = ns.ngrams_id
-- |]
selectNgramsOccurrencesOnlyByContextUser_withSample
::
HasDBid
NodeType
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment