gitbase-web icon indicating copy to clipboard operation
gitbase-web copied to clipboard

update example queries

Open smola opened this issue 6 years ago • 3 comments

Some gitbase-web examples look outdated, not using simplest syntax or not the most performance one. This needs a review by the gitbase devs to have optimal examples.

Example:

/* Commits per committer, each month of 2018, for each repository */
SELECT COUNT(*) as num_commits, month, repository_id, committer_name, committer_email
FROM ( SELECT MONTH(committer_when) as month,
              r.repository_id,
              committer_name,
              committer_email
    FROM ref_commits r
    INNER JOIN commits c
        ON YEAR(c.committer_when) = 2018 AND r.commit_hash = c.commit_hash
    WHERE r.ref_name = 'HEAD'
) as t GROUP BY committer_email, committer_name, month, repository_id

Shouldn't that be a NATURAL JOIN? Shouldn't the YEAR condition be in WHERE?

smola avatar Mar 08 '19 12:03 smola

cc @src-d/data-processing

carlosms avatar Mar 08 '19 12:03 carlosms

Talked with @ajnavarro offline, we'll be updating examples in gitbase-web, engine docs and gitbase docs.

smola avatar Mar 08 '19 15:03 smola

Also note that while this query is not written in the most clear way, its execution plan looks good and it's technically correct.

smola avatar Mar 08 '19 15:03 smola