We use Dynamo as the only data store at the company. The data is heavily relational with a well-defined linear hierarchy. Most of the time we only do id lookups, so it’s been working out well for us.
However, I come from a SQL background and I miss the more flexible ad-hoc queries during development. Things like “get the customers that registered past week”, or “list all inactive accounts that have the email field empty”. This just isn’t possible in Dynamo.
I understand Dynamo has very clear benefits and downsides. To me, not being able to just query data as I want has been very limiting. As I said, those queries aren’t meant to be added to the application, they’re meant to facilitate development.
How can I get used to working with Dynamo without needing to rely on that practice?
You can run all those queries as Scans instead of Queries. These will cost a lot more as you are charged for every record in the table but for a development database this shouldn’t be an issue.
I came from the same background and had this same observation. Now I’ve been working with Dynamo for ~1 year on my current team.
My observation so far is that Dynamo is good if you want to minimize maintenance costs, but it increases development costs. Relational DBs are usually the opposite. If you’re working on something where rapid feature development is vital (e.g. the core product of a startup) then relational is probably better. If you’re working on a simple service that just needs to be built and forgotten about (e.g. cache layer) then Dynamo is probably better.
It took me a while to get used to this dynamic, but I think it makes sense and it also helps communicate the tradeoffs to management better.
I think they want to run those queries on the production database but want to use the results to inform development. “Getting all new customers from last week” sounds like a question only the production database can answer.
Ah, missed the point of the question. This should apply even in production if the database is small and the scans are infrequent. If more complex analysis is needed, they could set up an ingestion system into S3 for local analysis.
I agree with your assessment. The downsides I feel are adhoc queries over large datasets (especially querying empty fields where Global Secondary Indexes aren’t an option) and DB aggregation functions count(), group by. Outside of these to me it is all upside.
In my day-to-day work I’ve gotten around this by exporting the data to analytics tools - I use Quicksight but only because it is in AWS - and performing these types of use cases there.
Couple other notes:
PartiQL is much closer to SQL when writing the queries. Similar to SQL though you still have to be aware of your query and the indexes it is using.
Choosing the right GSIs when designing the DB and then performing the query is central to performance.
another way of saying that is that if the data access patterns are well-known and stable, then ddb works. Otherwise, you might need the flexibility of relational.
Agreed, I’d probably set up an analytics service to handle these cases for a Dynamo architecture. Maybe have the Dynamo records exported to Redshift for flexible querying.
It’s a bit painful to set up, but I use Athena extensively to query all sorts of data from AWS, including sources like Cloudwatch logs, S3 files, RDS data etc. And having one tool to easily query it all in a consistent way is pretty useful.
IMO the answer is to use each tool for its purpose. Your DDB is for transactional application needs but your SQL probing is more “analytical”. If this is really important to building your service or supporting other teams (e.g. marketing), have your DDB export to a relational data warehouse and use that for your analytical queries.
If DDB scan doesn’t suit your needs, for analytical purposes you can full unload (once) and then periodically incremental export your DDB table to S3 and run queries normally there (Athena)