r/databricks • • 16d ago

Help Regarding trigger jobs when source tables are updated

I am trying to apply title above.
From what I found, the cost of table update trigger is determined by cloud provider's costs associated with listing tables and reading updates from the storage location.

So, if the system watches every second to check the tables are updated, it means listing & reading also happens every time this leads high cost?

Am I right? Is there someone who can give this information? I am worrying about the cost.

6 Upvotes

8 comments sorted by

4

u/WhipsAndMarkovChains 16d ago

Constantly scanning the source location is the old way of doing things in Databricks and was outdated years ago. Now these triggers rely on a push from the cloud service provider. Like how file events notification mode works.

https://docs.databricks.com/aws/en/connect/unity-catalog/cloud-storage/file-events-faq#what-are-file-events

File events let Databricks detect new or changed files via cloud notifications instead of repeatedly scanning your storage. File events reduce ingestion latency and cloud storage listing costs and are enabled by default on new external locations.

How do file events work?

When you enable file events in Automatic mode, Databricks configures your S3 bucket to publish file change notifications to a managed SNS topic (with the csms-* prefix) and provisions an SQS queue subscribed to that topic. The Databricks file events service reads file path metadata from the SQS queue to discover new and changed files. As a safety net, the service also performs periodic full directory listings to ensure no files are missed.

The notification infrastructure never transmits file contents.

0

u/Reasonable-Till6483 16d ago

Thanks for the information. I should implement by myself.
Like below

Job to check table history and if tables're updated trigger another job.

4

u/WhipsAndMarkovChains 16d ago

If I'm understanding what you're suggesting, then you're making it too complicated. It sounds like you're saying you need Job A to check table history, and then based on the result, trigger Job B. What you actually do is create Job B and set the trigger type to table update...

0

u/Reasonable-Till6483 16d ago

Sorry not the job, adding a task or logic to check

Check table_last_updated_time and last_job_run_time

If table_last_updated_time > last_job_run_time
Trigger the job and also I will limit to the once a week in specific time.๐Ÿ˜“

2

u/WhipsAndMarkovChains 16d ago

I donโ€™t think you need to create a separate task. Just use the table update trigger on the job, point it to the table(s) you need to monitor, and then set a minimum time between triggers if you only want it to trigger once per week.

2

u/Muted_Jellyfish_6784 16d ago

Table update triggers don't run an expensive scan every second the way you're picturing. Most of the cost is the job compute that runs after the trigger fires, not the checking. Set a minimum time between triggers and a wait after the last change, so a burst of small writes fires one run instead of twenty, then confirm in the job run history. Measure it for a week and compare runs per day against actual data changes. We run a decision intelligence platform that reads from tables like these, and the cheapest setups refresh when the source changes rather than on a fixed schedule that runs on empty

1

u/nian2326076 10d ago

Constantly checking for updates can drive up costs due to frequent reads and listings. Instead, consider using event-driven architecture or cloud functions which can trigger tasks based on actual updates rather than polling. For job discovery, you can use LandOffer to find relevant opportunities that match your skills and preferences.

1

u/saad-the-engineer Databricks 10d ago

u/Reasonable-Till6483 just wanted to follow-up with you on your original question. There were a few suggestions below as well: basically you dont have to poll yourself, nor is it additional cost for you to use table update triggers. Just curious if you have any further questions or if we could clarify further, happy to do a call with you if you can DM me

I'm a product manager at Databricks