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

Counting entities in dynamodb #129

Closed
Tamrael opened this issue Feb 7, 2018 · 5 comments
Closed

Counting entities in dynamodb #129

Tamrael opened this issue Feb 7, 2018 · 5 comments

Comments

@Tamrael
Copy link

Tamrael commented Feb 7, 2018

return $this->getAll($this->model->getKeyNames())->count();

Today we started using this class on one of our live products where we used dynamodb for simple logging only (reads on topics).

We only ever post the entry when the user reads the topic and read back a "read count" to display with each topic in the overview.

We had very low read and write rates before but after half a day of using the models instead of raw queries our read provision rates went trough the roof.

Turns out SomeModel::where('someField', $someValue)->count() doesn't actually result in a "Select" => "COUNT" statement to dynamodb but instead fetches all records and counts the collection.

Any chance this could be fixed?

Without a fix there is no point in using the model because all the clean code in the world can't justify a 50x increase in read provision rates

I'm willing to contribute a PR if wanted

@baopham
Copy link
Owner

baopham commented Feb 7, 2018

Ah yes, the count was done long time ago during POC time and I forgot about it. Hold on, let me see.

@Tamrael
Copy link
Author

Tamrael commented Feb 7, 2018

Thank you for the quick response. Let me know if i can help in any way

For reference: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html#DDB-Query-request-Select is the doc part describing COUNT.

@baopham baopham closed this as completed in 2b64163 Feb 7, 2018
@baopham
Copy link
Owner

baopham commented Feb 7, 2018

Will release a new version once Travis is green.

@baopham
Copy link
Owner

baopham commented Feb 7, 2018

Thanks for the report. The fix is now in version 4.2.3.

@Tamrael
Copy link
Author

Tamrael commented Feb 13, 2018

Thanks. Works like a charm. Keep up the great work

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

No branches or pull requests

2 participants