NIH study finds that coffee drinkers have lower risk of death  - <AUTHOR> http://www.nih.gov/news/health/may2012/nci-16.htm

<comment><USER2> _Researchers caution, however, that they can't be sure whether these associations mean that drinking coffee actually makes people live longer._

 _Also, information was not available on how the coffee was prepared (espresso, boiled, filtered, etc.); the researchers consider it possible that preparation methods may affect the levels of any protective components in coffee._

I wonder who pays for these studies... It seems like this article was written to be misquoted by tabloids all over the world.

</comment><comment><USER3> Just out of curiosity, am I crazy by _not_ regularly drinking coffee? Is there some benefit from it that I'm potentially missing out on, or will I perhaps be in for a rude awakening in a few years because of my lack of it? I do recall reading somewhere that people who did drink coffee vs those who didn't had better odds against things like Alzheimer's disease, so maybe that's one benefit..?

I'm completely serious in asking - I passed my 30th birthday a couple weeks ago and even for the past few years my aunt and others I know always ask how I get by without it. I have no aversion to it and would drink it if I needed a boost due to a poor night's sleep, but that would be maybe once every few months at most. This doesn't make me special at all so I'm not boasting or anything - the only reason I don't drink it(other than fear of stained teeth) is because I don't want to develop a need* for it, i.e. "I can't start my day until I've had that first mug". That would hardly be the worst thing in the world, but I'd just rather avoid it if I could.

For what it's worth I typically get 6-7 hours of sleep each night, and I exercise several times a week.

*I would typically use the word addiction, but that might be a little too strong given the context

<comment><USER4> Not everyone drinks it for the caffeine alone. It's quite delicious when prepared properly. So, I don't think you're crazy if you're not crazy about coffee's flavor.

<comment><USER3> > It's quite delicious when prepared properly. So, I don't think you're crazy > if you're not crazy about coffee's flavor.

Oh, I agree! A tall cup of Colombian with a shot of hazelnut is absolutely delicious. I can't drink it totally dark though, there has to be some type of creamer or sugar in it where I can enjoy it properly... but then there's the amount of calories in doing so.. but I digress :)

<comment><USER5> On the upside caffeine can reduce your appetite so it may be an overall win.

</comment></comment></comment></comment><comment><USER6> Doesn't everyone by definition have the same risk of death? ( _spoiler alert:_ it's gonna happen).

Shouldn't this read "lower risk of health-related death causes?" or something similar.

Seems like a link-bait type headline with a lot of sketchy information to be considered a scientific study.

Also, correlation /=/ causation.

 _Although we cannot infer a causal relationship between coffee drinking and lower risk of death, we believe these results do provide some reassurance that coffee drinking does not adversely affect health."_

<comment><USER7> _Doesn't everyone by definition have the same risk of death?_

It's risk of death over a specified period:

"The participants were followed until the date they died or Dec. 31, 2008, whichever came first."

<comment><USER6> It's still a misleading/confusing headline.

</comment></comment></comment><comment><USER8> From the submitted article:

"Neal Freedman, Ph.D., Division of Cancer Epidemiology and Genetics, NCI, and his colleagues examined the association between coffee drinking and risk of death in 400,000 U.S. men and women ages 50 to 71 who participated in the NIH- AARP Diet and Health Study. Information about coffee intake was collected once by questionnaire at study entry in 1995-1996. The participants were followed until the date they died or Dec. 31, 2008, whichever came first."

Collecting data about coffee use only once would of course miss collecting data about people whose habits changed during the course of the study.

"The researchers found that the association between coffee and reduction in risk of death increased with the amount of coffee consumed. Relative to men and women who did not drink coffee, those who consumed three or more cups of coffee per day had approximately a 10 percent lower risk of death."

Looking at the data to see if there is a dose response is a key issue in observational studies of this kind that many other studies miss. This isn't the last word on the subject, for the reason mentioned above and for other reasons mentioned in other comments, but at least here the study authors are treating coffee use as a quantitative independent variable and not just as a binary variable.

For the record, I began daily use of coffee (one cup each morning with breakfast) only after age forty. I asked around a long time before learning how to establish a habit that would not spiral into increasingly heavy use and physiological tolerance that would keep me upping my dosage for years and years and years. I come from a family with varying coffee-drinking habits but generally long lifespans.

</comment><comment><USER9> Food experiments suck. Coffee is a complex beverage. I see a few variables that must be isolated; caffeine and sugar intake being the biggest two. What do non-coffee drinkers drink more of on average? I'm guessing sugary sodas.

</comment><comment><USER10> Could there be selection bias? Stupid example theory: Habitual coffee drinkers do so because they have to wake up every morning to go to work, which is a population group that has a steady income and life, does not abuse substances and has access to healthcare. All factors that increase the length of life.

<comment><USER11> Completely anecdotal, I've known lots of people in lower income brackets that drink a ton of coffee.

</comment></comment><comment><USER12> For something like this, it's probably best as a non-specialist not to put too much weight on any one study, and wait for a good meta-analysis. There have been a _lot_ of studies on the effect of coffee drinking in various populations, on various diseases, and the results are not strongly consistent.

I seem to recall (but can't find a good reference at the moment) that one of the many puzzles in the area is why American studies more often find positive results than European studies; possibly relates to the kind of coffee consumed or methods of preparation, or possibly to interactions with other factors, or different demographic correlates.

</comment><comment><USER13> In other words: People who happen to drink coffee, for some reason that may or may not be related to coffee, live longer on average than people who don't drink coffee. Do people who don't drink coffee have lifestyles similar to those who do? On average, I highly doubt it. Observational studies are terrible when they generate headlines, but good when they generate controlled, scientific studies with proper isolation of variables. Since this is super expensive to do with humans as test subjects, it's not done very often, leading to piles upon piles of shitty science pertaining to human nutrition.

</comment><comment><USER14> I'd be interested to know if they controlled for employment. I imagine employed people are more likely to drink coffee, less likely to have disabilities, and more likely to have health insurance and better health care in general.

</comment><comment><USER15> "The researchers found that the association between coffee and reduction in risk of death increased with the amount of coffee consumed."

Unfortunately, drinking too much coffee in one go can kill you, as it is toxic.

<comment><USER11> The same can be said of water...

<comment><USER15> Sure, but I am not aware of a paper that claims that the more water you drink the longer you live.

<comment><USER11> They did not say that the risk of death decreases linearly with the amount of coffee that one drinks. Such a statement could possibly encourage people to drink amounts of coffee that could be detrimental to their health.

What they did say is that people that regularly drink 3+ cups of coffee a day seemed to correlate with decreased risk of death (over the period in question). In my opinion, this would only encourage people to take up drinking 3-4 cups of coffee a day. I do not see a risk of someone overdosing on coffee in response to this study.

</comment></comment></comment></comment><comment><USER16> I read this as, "Coffee increases your chances of living forever."

</comment><comment><USER17> Ehm, last time I checked risk of death was 100% for every human being.

But maybe coffee gives some odds?

</comment><comment><USER18> Effect is for three cups per day or more. I find more than 1.5 cups in a day... distasteful.

</comment><comment><USER19> Caffeine (used at strategic times) makes you care, boosting willpower and determination which brings success, success brings money and happiness, happiness makes you live longer. Too much caffeine has the opposite effect though. I want to know how much they consumed, not just that they did.

It's like saying a nitro boost usage in car racing causes winning. Yes, at a penalty of burning out the engine.

<comment><USER20> At a glance it seems to be a correlation so it could just be that people who live longer also tend to drink more coffee for whatever reason (maybe as you suggest they are driven, competitive, and use it to stay alert longer). I think the same is true for casual alcohol consumption.

In other words, it would be a stretch to suggest that coffee consumption is strictly beneficial.</comment></comment>


Startups - Get To Know Your Users  - <AUTHOR> http://blog.intercom.io/get-to-know-your-users/

<comment><USER2> The site doesn't provide much technical details but I'd be worried that aggregating data from disperate sources (potentially external) in order to identify and track users could run afoul of privacy laws and regulations. Particularly for companies operating in the EU or those in the US that have access to student, medical, financial or government data.

Also, I'm suspicious of a product that promises a seamless integration of disparate data sources. Anyone who has tried to do that within a company, and I imagine many of us have, knows just how tricky that can be.

I guess some additional details would be nice to have before I'm sold on the promise.

<comment><AUTHOR> Hey Jeff,

I understand where you're coming from. Your recent post on Privacy was very good.

It's up to each customer to choose what information they're comfortable sharing. On top of that business data we include communications, and usage data and we source publicly available profile data (though you can disable this if you wish).

In terms of seamless, the screenshots aren't faked. It's all there. It all works.

Send me a mail (des at intercom dot io) and I'll happily provide any extra details you want. You might find answers in the docs alternatively. <http://docs.intercom.io/>

Regards, Des

<comment><USER2> Hey thanks for the links to the docs. There's a lot of answers in there. I'll do my do my part and go through them before I email.

BTW, you should link that privacy policy from all your pages...

</comment></comment></comment><comment><USER3> Great post, by the end I was looking for the "buy button" you did a great job defining the problem and a nail that sticks out always gets hammered. ;)

</comment><comment><USER4> Have been using Intercom for our products for a few months already. It's fantastic! And our users love it a lot.

</comment><comment><USER5> I have heard lots of speak around this sort of user monitoring recently. Sure, sounds great but how important is it? Is it a priority for a startup?

Sure it may help in converting some new customers. May help existing customers. But is this where you want to spend your time and effort?

<comment><AUTHOR> Hey SparknLaunch12,

"How important is it"

Learning from your users is really important for start-ups. It's how you know when you hit MVP, it's how you know what your key values are.

But your userbase isn't one big mesh of people. There are active users, premium users, people who signed up once after clicking a HN link and never returned.

Being able to break your users down into groups (such as "ActiveMonthly") or "Enterprise" helps you get targetted feedback.

On a single user level, if you intend to talk with customers, it's massively useful to know exactly who you're talking to. You'll give a different pitch or response if you know the user has never created an invoice (filed a bug / uploaded a photo/ whatever).

As always, the best way is to give it a try. We find it incredibly useful.

</comment></comment><comment><USER6> Des, where is Intercom based out of?

<comment><AUTHOR> Hey Chris,

San Francisco and Dublin (Ireland)

Des</comment></comment>


Baidu Claims First 'Large-Scale' ARM Server Deployment - <AUTHOR> http://www.datacenterknowledge.com/archives/2013/02/28/baidu-deploys-marvell-arm-based-server/

<comment><USER2> From the article: "the Marvell server SoC is unique in its ability to deliver the low power consumption, high storage and computer density"

Does anyone know of any numbers on these? This is pretty much the crux of the reason to switch to ARM/RISC processors in general, yes?

<comment><USER3> I'm seeing 15 W reported for Dell's ARM server; that seems pretty high for the performance you get.</comment></comment>


PostgreSQL Count(*) Performance Improvements - <AUTHOR> https://www.cybertec-postgresql.com/en/count-made-fast/ <comment><USER2> The headline makes it sound like they did work to _improve_ the performance of count(*) in the postgres code, when that's not at all what the article is about.

This post from Citus is far more informative:

[https://www.citusdata.com/blog/2016/10/12/count- performance/](https://www.citusdata.com/blog/2016/10/12/count-performance/)

<comment><USER3> +1. Citusdata article is much better.

</comment></comment><comment><USER4> Given the title, I expected this to be about how PG improved their counting. This is not what it was about.

I remember working over half a billion records and having problems when I needed a count. I used count(id) but that was mainly from internet mantra. I did not see an improvement. Using Citus gave me a significant improvement from 7 minutes to 1. And that was just a single coordinator, two workers on the same host. It could become much much better.

If the data is very stagnant and writes are very low the triggers are great. Usually the "close enough" with pages is good if you have over 100k since paging - please correct me if I'm wrong - is sometimes 1k off.

My preference is Citus as a catch all, but a trigger, a Redis cache managed at the app level, or using page counts are all . really useful for stickier situations.

<comment><USER5> As an alternative to page counts, we used HLLs to estimate (unique) cardinality, and were quite happy with it. There is a postgres extension (postgresql-hll) and also a version for the JVM using the same algorithm/data format.

</comment></comment><comment><USER6> Sorry for being a bit off topic, but anyone out there who is using PostgreSQL in production, how do you manage tables with lots of updates? Is auto-vacuum doing good enough job for you or do you have to run "vacuum full" regularly?

<comment><USER7> For our use case, we found the best approach was to clone all of the data to a temporary table with indices and constraints disabled, perform the updates, re-enable indices and constraints, and then replace the production table with the temporary table. This only works if you are able to update your data in bulk, and if some lag time in your updates is OK. This also has the benefit of never locking your production table.

In situations where real-time updates are important, the key is to minimize your indices as much as possible. Read up on heap only tuples (HOT). If that all isn't enough, maybe consider sharding your database.

Never run VACUUM FULL; it locks too aggressively. Let autovacuum do the job.

</comment></comment><comment><USER8> | A note about count(1) vs count(* ). One might think that count(1) would be faster because count(* ) appears to consult the data for a whole row. However the opposite is true.

Which is the opposite decision of other databases. So sometimes Postgres _does_ make bad decisions...

<comment><USER9> I think the "the opposite is true" is in reference to the assertion that "count(⧆) appears to consult the data for a whole row", not to the proposition that "one might think that count(1) would be faster [than count(⧆)]".

count(⧆) just counts the tuples themselves, which is fast; it's like counting heap-allocated data structures by counting their pointers (which you're already walking), without dereferencing those pointers.

count(1) counts the result of evaluating the SQL expression "1" upon landing on each row, but still walks the same pointers to do so.

So, in terms of time complexity, they're roughly equivalent. Both data items (the tuple and the SQL constant expression) are already on the stack, ready to be directly computed upon.

Postgres's count(1) isn't slower than the one in any other DBMS. It's just their count(⧆)—at least the expression-evaluation part of it—which is _more_ optimized than the one in other DBMSes. Nothing wrong with that, IMHO.

<comment><USER10> > Postgres's count(1) isn't slower than the one in any other DBMS.

count( * ) is faster on Postgres than count(1). But both are fundementally slow because of MVCC. And count( * ) on postgres (the optimized one on Postgres) is much slower than count(1) on other databases (the optimzed one on other databases). So practically speaking, counting rows is slower on Postgres than on other databases.

That said, I love Postgres. I use it every day. There is some room for improvement and it does improve all the time. It is an amazing open source project. And I wouldn't care at all if they never optimize count(1)

<comment><USER9> Yes, I was trying to make a finer point—the _difference_ between count(⧆) and count(1) comes down to the cost of _filtering_ the row, and in Postgres count(1) is a regular filtering operation—taking the same _filtering cost_ that count(1) has in other DBMSes—while count(⧆) has a _filtering cost_ that is lower than that of other DBMSes, because it has been specifically optimized†.

Separately, there's an MVCC cost of _walking_ the rows to filter them, and other DBMSes optimize walking rows for counting [usually causing both count(1) and count(⧆) to be faster], while Postgres does not do this optimization. (And, as stated in the article, in those DBMSes, this isn't a pure optimization _per se_ , but is rather a trade-off, trading write speed for all INSERTs/DELETEs for read speed for this particular case.)

(† Technically, the filtering cost of count(⧆) hasn't been _specifically_ optimized; the relative speed of filtering tuples for count(⧆) is an emergent property of the general fact that Postgres treats any mention of `⧆` as a reference to the row-tuple object itself. i.e. If `foo` is a table (x int, y text), then in actuality, `foo` is first created as a type [a pg_class] defined as the tuple (int, text); and then the table `foo` is defined as a relation persisting a rowset of `foo`-tuple-typed rows [in est making a table['s triggerable operations] each into a stored procedure with a `foo`-tuple-typed-rowset return type.] Then, the expressions `(SELECT ⧆ FROM foo)`, and `(SELECT f.⧆ FROM foo f)` both evaluate to rowsets type `foo`, which means that Postgres doesn't need to dereference the pointer to each `foo` heap tuple to build those rowsets. It only needs to dereference the pointers when it comes time to actually serialize and emit the row over the wire—which in case of a `count(⧆)` operation, never happens.)

</comment></comment></comment></comment><comment><USER11> It is not count( _) that is slow, it is iterating through the rows that is / can be slow :)

For me, the trick to basic understanding of perf in PG was exactly this: it is all about limiting the amount of rows you have to iterate over. It is true for count(_) but also for every other operation you do.

PG is surprisingly non-magical (at least in my experience) in that you won't get much perf for free, but on the other hand you can reason about perf & optimize pretty reliably once you come to terms with this.

</comment><comment><USER12> Note the trigger approach mentioned in the article would be terrible for performance in a concurrent environment, since only one transaction could modify the whole table at a time.

<comment><USER13> I wonder if there's a way to "shard" these counters to avoid this problem.

If you had 10 different counters (maybe in ten different tables) and a mechanism for round-robin or randomly selecting which counter gets incremented/decremented would that allow ten concurrent transactions at once?

The query to return the total count would then need to sum the 10 individual counters, which should be extremely fast.

Or is the concurrency limitation here caused by the trigger on the counted table itself, not the writes performed by the trigger?

<comment><USER14> Even though only 1 / 10 counters would be locked, you'd still have to read all 10 to get the count, which would be blocked until the concurrent transaction ended.

<comment><USER15> With MVCC writers don't block readers.

</comment></comment></comment></comment><comment><USER16> I appreciate approaches that acknowledge when "close" is good enough. It would be interesting to graph how far off those numbers are to put a real metric to it.

<comment><USER17> Only one data point, but I've got a custom search engine for a community that has pretty close to the ideal usage pattern for this: append-only with no update or deletes. A pure count(*) over 6.8M rows on a slow VPS takes 135,015ms and the n_live_tup technique¹ takes 214ms. The latter was 00.009557% high before an analyze and 00.001414% low afterward. Definitely good enough for me.

¹ SELECT n_live_tup FROM pg_stat_all_tables WHERE relname = 'comments';

</comment></comment><comment><USER18> The author claims that the tally method using "mytable_count" is concurrency safe.

On the one hand, I think that is great. On the other hand, I am still suspicious.

</comment><comment><USER19> This title should be "Fast explanation on why PostgreSQL count(*) is slow" or something like that

</comment><comment><USER20> Nothing to see here, move along.

Been using this since 2009 [https://wiki.postgresql.org/wiki/Count_estimate](https://wiki.postgresql.org/wiki/Count_estimate)

<comment><USER21> Be careful with this if your postgresql release is not up to date. There was a bug in the way ANALYZE updated pg_class.reltuples that could cause the value in reltuples to grow incorrectly for large tables. If the table had a lot of updates the pg_class.reltuples value would tend to increase a bit each time it got updated.

This was fixed in March 2018 and was backpatched so any binary release since then should be ok, eg 9.x.latest 10.x.latest, 11.x.

See [0] for details of the bug.

[0] [https://www.postgresql.org/message- id/flat/20180117164916.3f...](https://www.postgresql.org/message- id/flat/20180117164916.3fdcf2e9%40engels)</comment></comment>


Ask HN: How often do you work from home? - <AUTHOR> I was talking to a colleague about working from home, and what a healthy amount of it looks like. I mentioned that among my peers it seems like most get at least 1 day a week from home, which to me seems like the perfect number. He told me that he thinks 1 day every two weeks. I have interviewed for companies that allow 2 days from home per week, which to me seems like too much.<p>How often do you work from home? Is it good for your productivity? Your work/life balance? <comment><USER2> Two days a week. If my work environment continues to get louder/more crowded, I'd likely move up to three.

As I type this, I can overhear 3 distinct conversations, over my headphones. I am _vastly_ more productive at home. Coworkers tend to make async pings over chat rather than walking over to context switch you. There's less visual/audial distractions. There are less spurious discussions, since someone can't just "Grab you." I additionally have more desk space, a more comfortable work environment, and a generally more peaceful surrounding at home.

(This on top of the obvious benefit of gaining 2 hours back of every day, and throwing off all the stress that comes via sitting in traffic for those 2 were I commuting)

After a mix of personal offices and open spaces over the last decade, having a door, or the ability to work largely remote, have become significant drivers in my career choices. The quality of life is just so much higher.

</comment><comment><USER3> I have been working from home 2 days a week for the past year. It is usually Tuesday and Thursday. I have about a 3.5 hour round trip commute, so I just asked if it was ok if I worked two days from home and my boss was fine with it and his boss was fine with it. I also see many doctors and so I make sure to schedule all my appointments on a Tuesday/Thursday.

I'm typically at the same level of productivity when working from home as I am in the office. There are distractions in both areas. At home, it is the dogs and at the office it is coworkers.

</comment><comment><USER4> I work from home all the time. In fact I have been doing it for the past 11 years.

Some places I've also WFH-ed at: my car, on bus & train, on aeroplane just before taking off, car dealer, co-working spaces or friends and/or customer offices, various hotels and cafes, etc. I've even been on motorcycle trip where I've had to pull over and get something urgent done before reaching my destination.

The key to everything is discipline, a bit of preparation and being diligent with your work. At the end of the day most bosses don't care where you are (I've never seen mine, nor the team I work with in person, they are half-way across the world) as long as your job is done, preferably very well.

To be clear I started working remotely out of necessity but I've had an eurika moment when I read "The 4 hour work week" by Tim Ferris. This is one of my all time favorite books and I strongly recommend reading at least some chapters from it if you intend to work from home.

</comment><comment><USER5> At least once a week, usually more. Often, those are the most productive days: Sitting in a comfortable, familiar environment to my liking, and being able to focus on code (or whatever else is at hand) without distractions. Not having to prepare for work and commute helps a lot, too, in terms of wasted time and psychologically.

In fact the pure knowledge of not having to get up early and go through the whole morning routine to spend all day in my office often suffices to make the evening before feel like it's going to be a weekend day the next day, despite the usually increased productivity.

As for meetings, I don't like to stay home for meetings that I substantially care about, because I think that even with video conference a lot of communication bandwidth is lost, but for meetings where my attendance is merely necessary, it works very well.

</comment><comment><USER6> Never!

This is great for work/life balance. I'm not tempted to even be aware of work when I am at home. I can devote my time fully to my family.

I will admit to a few other things that help productivity and work/life balance:

1\. I get solid office walls. Some work locations are behind multiple layers of heavy doors.

2\. I get extreme flex-time, so I can show up and leave at strange and random hours. This is really helpful for dealing with any family issues that may arise.

3\. I'm only expected to work 40 hours per week, for real.

4\. My commute is 3 minutes by car or under 20 minutes by foot. It's just 0.9 miles. This is the benefit of not living in an urban environment. There is a small house right behind my workplace (you could commute via pole vaulting) that is expected to go for $180,000.

</comment><comment><USER7> I WFH 1 day per week, on Wednesday. I am actually more productive on Wednesdays because I don't get bothered by coworkers, and I am able to focus on what I need to do. I would prefer 2 days from home per week honestly.

</comment><comment><AUTHOR> I work from home for 1 day a week. While it may not be the MOST productive day I get out of the week, overall I think it prevents me burning out on my coworkers, and my company overall. It's worth mentioning I am a developer, so the work lends itself to being manageable remotely.

</comment><comment><USER8> Every day, for almost 20 years now</comment>