-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Metric repository perf #2040
Metric repository perf #2040
Conversation
use CachetHQ\Cachet\Repositories\Metric\MySqlRepository as MetricMySqlRepository; | ||
use CachetHQ\Cachet\Repositories\Metric\PgSqlRepository as MetricPgSqlRepository; | ||
use CachetHQ\Cachet\Repositories\Metric\SqliteRepository as MetricSqliteRepository; | ||
use CachetHQ\Cachet\Repositories\Metric\MySql as MetricMySqlRepository; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like these renames. ;(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping it how it was. :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, okay then. I'll rename them once it's finished.
public function getPointsSinceMinutes(Metric $metric, $minutes) | ||
{ | ||
$queryType = $this->getQueryType($metric); | ||
$points = Collection::make(DB::select("SELECT DATE_FORMAT(metric_points.`created_at`, '%H:%i') AS `key`, {$queryType} FROM {$this->getTableName()} INNER JOIN metric_points ON metrics.id = metric_points.metric_id WHERE metrics.id = :metricId AND metric_points.`created_at` >= DATE_SUB(NOW(), INTERVAL :minutes MINUTE) GROUP BY HOUR(metric_points.`created_at`), MINUTE(metric_points.`created_at`) ORDER BY metric_points.`created_at`", [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are absolutely disgusting... 😱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Laravel 5.3 stops us having to wrap DB::select
in a collection at least.
The issue we have with all of the metrics is that each DB driver queries differently and Eloquent isn't flexible enough to allow us to keep the same query structure — unless I'm missing something? I really want to get this into 2.4, so I'll try and finish this at a later date. |
2f02441
to
a791656
Compare
Rebased. |
a791656
to
74c646e
Compare
[ci skip] [skip ci]
This is finally done! |
😱 👍 |
Closes #1900.
Refactoring metrics. With this, I intend to fix the performance of metrics across all three database drivers.
Note that this is probably going to end up bigger than I intended it to be, but it'll make it easier to deal with.
Todo: