dokuzbir
I want fetch time datas without specify minutes . So with one query, can i fetch these two times time: ~T[21:30:00] and time: ~T[21:15:00] ?
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Ankhers
You can use
Time.add/3to get from your start time to the end time.dokuzbir
Thanks. What do you think about effiency of that code? Or should i splite time column to two different column :hour and :minute ?
dimitarvp
The efficiency of that query depends on your database, not on your code. If you are so concerned, add a DB index to the column holding the timestamps.
Never do premature optimization.
Ankhers
I’m not really sure how efficient it is. But I don’t really see it being bad. You could also try using a fragment to search.
Keep in mind I haven’t tested the above, but it should work, or something close to it anyways. Take a look here for functions to process dates and times within postgres.
blatyo
I tend to favor @Ankhers first approach as opposed to extracting the hour out in the query. That’s simply because the database must now run that operation on every row. If you have an index on the time column, you won’t be able to use it, unless the index is for the specific operation you’re performing.
In short, favor doing the work once, rather than many times.
blatyo
I don’t think it will make much difference. The only benefit I see is that it may make the work you do before the query simpler.
dokuzbir
So if i understand right, @Ankhers’ s first approach better for indexes?
blatyo
The second approach could work fine if you had an expression index for it. But it would have to be a separate index from an index directly on the time column. So, you could end up with two potentially.
All of this is completely dependent on the situation though. If you have some other column you also always query on, it may reduce the result set, such that either solution is perfectly fine. I tend to avoid most indexes until it’s obvious they’re necessary. Before, I would try to pre-empt what indexes would be useful and later find most of them are unused because another one gave better performance, so the query planner always picked it. Having unused indexes affects write performance without any gain. Just watch your slow query log and you’ll be able to see what needs optimizing.
dokuzbir
I actually had
date:string, hour:integer, minute:integercolumns. I started refactor my app todate:date , time:timecolumns. After comments i decided onedate_time:naive_datetimeand index. I dont know how postgresql works behind scene. My story is fetching booking slots depends on court_id and date. New problem is only court_id index works well ? or both court_id and date indexes? What do you think about having 2 indexes in same table ?blatyo
If you’re going to always query two columns you should use a compound index, not one for each field. In most circumstances, a database can only use one index at a time.