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

update example queries #363

Open
smola opened this issue Mar 8, 2019 · 3 comments
Open

update example queries #363

smola opened this issue Mar 8, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@smola
Copy link

smola commented Mar 8, 2019

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 smola added the enhancement New feature or request label Mar 8, 2019
@carlosms
Copy link
Contributor

carlosms commented Mar 8, 2019

cc @src-d/data-processing

@smola
Copy link
Author

smola commented Mar 8, 2019

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

@smola
Copy link
Author

smola commented Mar 8, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants