HNHacker News
TopNewBestAskShowJobs

zac23or

755 karma · joined August 1, 2018

submissionscomments
zac23or··on Apple users are being locked out of their Apple IDs with no explanation
> Someone made ...

This example demonstrated to me that Apple is a religion, after many other examples. Try reading Apple's blogs, it's crazy.

I recommend not trying to talk to extremists in any area. Your life will be much better.

zac23or··on Apple users are being locked out of their Apple IDs with no explanation
Apple is like a religion. An Apple user told me “Apple never makes mistakes” during the Antennagate. I never forgot that, and I try not to have conversations with Apple fans after that.
zac23or··on Leaving Rust gamedev after 3 years
I also had the same bad experience with Rust outside of Gamedev. Probably a lot of other people too, but people don't talk about it much, because the Rust community is the most religious programming language community I've ever seen in my life. Before Rust, the Scala community was also pretty bizarre (Java too for a while), but nothing was on Rust's level. The worst part about Rust isn't technical, it's the crazy community. You can see in the article that the author tries to explain everything at every point, trying to escape the problem "If you don't understand something in Rust, you're holding Rust wrong."

Of course, there are many people in the Rust community who are not religious and try to improve the language, but my general feeling after reading a lot about Rust is to stay very far from the church of Rust.

The best response to this type of community is humor, like this video about a Rust Senior developer https://www.youtube.com/watch?v=TGfQu0bQTKc

zac23or··on Read Google's memo warning employees to 'think again'
Flagged again. Is HN like this now?
zac23or··on Good news against dengue
> but for rural areas I suspect is not feasible?

Aedes aegypti is an urban mosquito. Degue is an urban disease. The big difference between Brazil and Singapore is sanitation: https://en.wikipedia.org/wiki/Water_supply_and_sanitation_in...

zac23or··on Good news against dengue
0.16% of Singapore's population had Dengue in 2022. 1.4% of Brazil's population had Dengue in 2023.
zac23or··on Good news against dengue
Are you comparing 8k cases (Singapore) with 3 million cases per year (Brazil)?
zac23or··on Good news against dengue
Singapore had 8 thousand cases in 2022. Brazil has 3 million cases of dengue in 2024.Is not the same thing. The poor distribution of water and the lack of sewage are fundamental to dengue fever in Brazil.
zac23or··on Good news against dengue
> Dengue is just a difficult thing to fight

Singapore had 8k cases in 2022. Brazil has 3 million cases of dengue in 2024. Is not the same thing.

zac23or··on Good news against dengue
Singapore had 8 thousand cases in 2022. Brazil has 3 million cases of dengue in 2024. Is not the same thing.
zac23or··on Good news against dengue
Dengue is not a tropical disease. That does not exist. Dengue is a disease of bad governments.

In Brazil, the majority of the population does not have sewage. Tap water is not potable and is not distributed every day, in some areas twice a week, in some areas less than that. This creates the need for everyone to have a water tank at home, creating the possibility of a large number of mosquito breeding sites. And the Moskito Aedes aegypti is a terrible vector of 52 diseases [0], among which it transmits a sarcoma (!!!) among hamsters.

The current government tried not to buy vaccines[1], trying to wait for the Butantan vaccine.

The current Brazilian government is the same or worse (!) than the previous one, more censorship, more dead Indians[2], more fires in the Amazon rainforest[3], and one thing is really worse: all the press covers up the mistakes of the current government .

And...politicians are crazy, intelligent, incredible psychopaths. In the last two weeks the discussion has been about freedom of expression, about Elon Musk and so on. Economy, education, security and health are never priorities. It's clear that the government is trying to pass a law to regulate social media (and using Musk and Twitter as an example to do so), and the mainstream press is very eager to do so, because the law has a part that states that social media will pay for links to news sites. It is not a problem for a country that needs sewage.

They are incredibly good at doing nothing. Some things in Brazil have been discussed for over 100 years, an example is a tunnel in the city of Santos[5].

The next government will also be bad, the population will fight over policies and nothing will change. I will never understand why people fight for these psychopaths. "My psychopath is better than yours."

Please, I will not discuss “fascists” or “communists”, left or right, “everything is politics”, “but billionaires are bad”, etc. These are first-world problems. It is irrelevant for a country that needs sewage. Of course this can be discussed, but not in the current proportion. Sewers are much more important than that.

[0] https://en.wikipedia.org/wiki/Aedes_aegypti#Vector_of_diseas... [1] https://saude-ig-com-br.translate.goog/2023-07-03/dengue-min... .html?_x_tr_sl=pt&_x_tr_tl=en&_x_tr_hl=pt-BR&_x_tr_pto=wapp [2] https://g1-globo-com.translate.goog/jornal-nacional/noticia/... -2022-showm-dados-do-ministerio-da-saude.ghtml?_x_tr_sl=pt&_x_tr_tl=en&_x_tr_hl=pt-BR&_x_tr_pto=wapp [3] https://umsoplaneta-globo-com.translate.goog/biodiversidade/... -aponta-estudo.ghtml?_x_tr_sl=pt&_x_tr_tl=en&_x_tr_hl=pt-BR&_x_tr_pto=wapp [4] https://g1-globo-com.translate.goog/sp/santos-regiao/noticia... -no-novo-pac.ghtml?_x_tr_sl=pt&_x_tr_tl=en&_x_tr_hl=pt-BR&_x_tr_pto=wapp [5] https://g1-globo-com.translate.goog/sp/santos-regiao/noticia... -no-novo-pac.ghtml?_x_tr_sl=pt&_x_tr_tl=en&_x_tr_hl=pt-BR&_x_tr_pto=wapp

zac23or··on Why choose async/await over threads?
Async and Thread are of different abstraction levels[1]. The easier to use, the higher the abstraction level.

Rule of thumb: use the highest level of abstraction for your case.

Of course, the Async implementation can be atrocious or in conflict with something already used by your code, forcing you to use a lower level of abstraction.

[1]https://blog.codinghorror.com/the-wrong-level-of-abstraction...

zac23or··on -2000 Lines of Code (2007)
Counting lines of code as a production metric is very stupid. I remember solving an unsolvable 20 years old bug with a line of code, another 3 years old with a order by. How to measure the impact of a line of code? And in my experience, bad programmers write a lot more code...

I will never forget the story[1] of a Microsoft developer rewriting a piece of IBM code that had 33 thousand characters, after rewrite ... 220. This generated a war because MS's work was... negative.

[1] https://archive.org/details/bigbluesunmaking00carr/page/4/mo... page 101

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
> how organization_id is being generated

The default value of the column:

  organization_id int default floor(random()*10)
> Also, if each page contains data from all organizations then sounds very much like it's not clustered by organization_id

The sample data is clustered by foo_created_at_idx, I changed it to be clustered by foo_organization_id_idx

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
In my old tests, with data clustered by organization_id, the SQLite and SQLServer run the query very fast.

> is not to be so certain that there is "a correct query plan"

Yes, data distribution, type, row size, machine power, SSD vs HD can affect which is the “best plan”.

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
The sample data is distributed equally, each page contains data from all organizations. The actual data is much more grouped by organization, like this:

  insert into foo (id, created_at, updated_at) select generate_series(1, 4000000),
    generate_series('2010-01-01 00:00:00'::timestamp, now(), ('2010-01-01 00:00:00'::timestamp - now())/4000000),
    generate_series('2010-01-01 00:00:00'::timestamp, now(), ('2010-01-01 00:00:00'::timestamp - now())/4000000);

    cluster foo using foo_organization_id_idx;

    vacuum analyze;
Clustered by organization, the best index is organization_id_idx;
zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
I agree with everything you said, but it's frustrating that the planner fails on a seemingly trivial query ("seemingly trivial", perhaps it's a very complex problem).

> So it takes time to get new stuff in.

It's true, I discovered this problem in PG 9, and it's true in PG 16, if I'm not mistaken.

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
foo_organization_id_idx is the correct index, in my case using foo_organization_at_idx is 100x, 1000x faster.

In all my queries, the correct index is in the where clause, not the order by clause: When I removed the use of the wrong index, (ORDER BY update_at + range '0 day' forces the use of the correct index), the query used less resources and was much faster.

Of course, there may be cases where the index in the order by clause is the best one to use, but in my use this never happened.

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
See https://news.ycombinator.com/item?id=39730206
zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
I changed random_page_cost to 1! The query continue to use the wrong index.
zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
You reproduced it. See the index being used. foo_updated_at_idx, not foo_organization_id_idx. See a FILTER on Organization_id, not a Cond index. If you create an index using Organization_id and updated_at the plan changes to:

  Limit  (cost=0.42..3.26 rows=10 width=24) (actual time=0.013..0.024 rows=10 loops=1)
     ->  Index Scan using foo_organization_id_updated_at_idx on foo  (cost=0.42..2011.50 rows=7063 width=24) (actual time=0.012..0.023 rows=10 loops=1)
         Index Cond: (organization_id = 1)
   Planning Time: 0.154 ms
   Execution Time: 0.033 ms

Now the plan is using Index Cond, not filter.
zac23or··on How web bloat impacts users with slow devices
> If you want to blame LE for the breakage then also blame ...

Of course they are also guilty. LE isn't the most to blame in reality, it's just an example that old hardware isn't important to decision makers.

zac23or··on How web bloat impacts users with slow devices
Product Owner
zac23or··on How web bloat impacts users with slow devices
Nobody, nobody, nobody cares about old hardware, performance, users, etc. if anyone cared, React wouldn't be a success. The last time I tried to use the react website on an old phone, it was slow as hell.

LetsEncrypt is stopping serving Android 7 this year. Android 7 will be blocked from 19% of the web: https://letsencrypt.org/2023/07/10/cross-sign-expiration The option is to install Firefox.

Users with old hardware are poor people. Nobody wants poor people around, not even using their website.

“Fuck the user”, that's what we heard from a PO when we tried to defend users, imagine if we tried to defend poor users.

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
> It's really hard to say why this is happening without EXPLAIN ANALYZE

I can run EXPLAIN and paste it here, but it's just one of the problems with the planner (in a very basic query), I have many other problems with it.

On the other hand, I've never had any other serious problems with Postgres. It's a very good database.

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
seq_page_cost is 1; random_page_cost is 2;

I have many other problems with the planner, this is the most absurd due to the simplicity of the query.

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
> Logic of optimizer is usually reasonable

I agree. My problem is that SQLite, an embedded database, seems to have a better Planner/Optimizer than Postgres.

Is the development of Planner/Optimizer abandoned?

> my problem with it is that it relies on cost config parameters

And I don't have access to change it, as it's a PASS database...

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
>Pg stats are messed up somehow. Try running explain analyze foo

I did

> Postgres doesn’t automatically create indexes

Both fields have indexes (created manually). Postgres is incorrectly choosing the index in order by column, not the index in the where clause.

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
> it sounds like you don't have a single index that covers both columns.

Yes. But other databases (SQLlite, etc.) select the correct index, without the need to create an index with both columns.

zac23or··on Pg_hint_plan: Force PostgreSQL to execute query plans the way you want
My biggest problem with Postgres is the Planner/Optimizer. The worst example is a super simple query:

SELECT * FROM TABLE FOO WHERE ORGANIZATION_ID = 10 ORDER BY CREATED_AT LIMIT 10 OFFSET 0;

Postgres sorts by created_at using an index, but uses the filter on organization_id. This organization has a million rows... without the order, the query runs in ms. In order, in seconds/minutes.

Sometimes the plan changes if you change the query offset!

For organization 10, the plane is goood, for organization 11, the plane is bad...

Change stats, add more stats, fill the void. that doesn't solve anything. The solution is to use a calc on order by , but in the end you need to create an index using Organization_id and created_at to really fix it.

I did the same test on SQLServer and SQLite, they executed the query correctly, using the correct index. I've never created an index to fix a bad plan in SQLServer, and I've used SqlServer a lot more than Postgres.

And I use a Pass database, it's impossible to install extensions...

I'm going to test this extension locally, if it works I'll convince the company to use it (by changing the database provider)

← PreviousPage 2 of 7Next →