Hacker Newsnew | past | comments | ask | show | jobs | submit | jiaaro's commentslogin

Exists is a useful tool that you should certainly know how to use. Whether or not it's faster than distinct depends on the rest of the query. I've optimized queries where distinct is faster than exists. It's been some time, but I think it boils down to the relative sizes of the tables and how many of the exists queries actually find something (and how often they find more than one something).

Also, some databases (like clickhouse) allow for `any` joins which avoid producing duplicate rows. For example:

    select author.*
    from author
    inner any join book on (
        book.author_id = author.id 
        and book.title like 'Book%'
    )


Cool project! But, I wonder how long can a project like this use a Pokemon as their namesake and mascot before you hear from nintendo's lawyers?


I wonder if they could get away with an extra L and using ascii art of the pokemon...


ascii art for the win


Right up until they start charging


Random and round robin partitioning are the configurations being discussed.

The main point of the article is that low message volumes mean you can get unlucky and end up with idle workers when there is still work to be done


The linked article says, in reference to Oracle relocating its HQ to Austin:

> Oracle, which was founded in Santa Clara, Calif., in 1977, later had its headquarters in Redwood City. The software giant, at the time of its move to Texas, said that relocation was to allow a more flexible approach to its workforce

> The company had neither asked for nor received economic incentives from Austin to relocate, said city officials. Nashville pledged $175 million in incentives and the state of Tennessee $65 million to help build the Oracle campus in 2021


So it would be technically correct to say that Oracle has not returned any tax incentives to Austin.


The main difference is that you wouldn’t instead drive the whole way instead once you find out the risk. But people do drive the same places they fly


Do they? I’ve never driven from San Francisco to Taipei or London.

But even in context, they’re talking about “the drive to the airport.” Do they drive hundreds/thousands of miles to get to the airport?


If you use postgres, psycopg provides `cursor.mogrify(query, params)` which returns the actual query that will be executed . For example:

    cursor.mogrify(*queryset.query.sql_with_params())
Alternatively, you can set the log level of the `django.db.backends` logger to DEBUG to see all executed queries


https://docs.djangoproject.com/en/5.0/topics/db/sql/ :

> Django gives you two ways of performing raw SQL queries: you can use `Manager.raw()` to perform raw queries and return model instances, or you can avoid the model layer entirely and execute custom SQL directly.

https://stackoverflow.com/questions/1074212/how-can-i-see-th... has :

  MyModel.objects.all().query.sql_with_params() 
  str(MyModel.objects.all().query)
And:

  from django.db import connection
  from myapp.models import SomeModel
  queryset = SomeModel.objects.filter(foo='bar')
  sql_query, params = queryset.query.as_sql(None, connection)
  
  with connection.connection.cursor(cursor_factory=DictCursor) as cursor:
      cursor.execute(sql_query, params)
      data = cursor.fetchall()
But that's still not backend-specific SQL?

There should be an interface method for this. Why does psycopg call it mogrify?

https://django-debug-toolbar.readthedocs.io/en/latest/panels... :

> debug_toolbar.panels.sql.SQLPanel: SQL queries including time to execute and links to EXPLAIN each query

But debug toolbars mostly don't work with APIs.

https://github.com/django-query-profiler/django-query-profil... :

> Django query profiler - one profiler to rule them all. Shows queries, detects N+1 and gives recommendations on how to resolve them

https://github.com/jazzband/django-silk :

> Silk is a live profiling and inspection tool for the Django framework. Silk intercepts and stores HTTP requests and database queries before presenting them in a user interface for further inspection


`str(queryset.query)` does not give you executable SQL. Query parameters are not escaped or encoded in that representation of the query. That escaping/interpolation of query parameters is performed by mogrify. I agree the name is odd, and I don't know why they use it other than "transmogrify" being an obscure word for "magically transform".

debug_toolbar and silk are both tools that show you what queries were executed by your running application. They're both good tools, but neither quite solves the problem of giving you the executable SQL for a specific queryset (e.g., in a repl).


There are a number of solutions listed in that stackoverflow post for logging queries, but AFAIU none call mogrify().

Maybe it should be called dialectize() or to_sql(parametrized=True)


On the other hand, these things see a lot more annual miles than consumer vehicles so the payback period should be shorter. I agree though, that probably it would require some kind of government involvement to get broad adoption.

Also, I imagine it's easier to find extra space for batteries in the the trailer than the tractor.

Regenerative breaking seems like a more important improvement though.


I think the suggestion is that a spreadsheet is the not the right tool for the job.

There is very likely value in dedicated genetics-specific software, even in the form of an excel add-on.

[edit] Here's one, and it's free: https://biology-assets.anu.edu.au/GenAlEx/Welcome.html - so maybe this change from microsoft was necessary


maybe some statistical analysis software is more useful - for e.g. minitab


Based on the paper Dang linked, it appears that epoxy is involved in all queries to all data stores it coordinates


Does Epoxy use postgres' own transaction ids across datastores? If not, does it implement its own "transaction id horizon" like postgres has so that you can assume all transactions before a certain counter are committed?


Yeah, our implementation uses Postgres transaction IDs across data stores.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: