Show HN: I wrote a free eBook about many lesser-known/secret database tricks
sqlfordevs.com
sqlfordevs.com
Since every message in the constant social media stream vanishes after a few days, I had to do something about it. Knowledge must be preserved. I sat down for a few weeks and reworked every example and every text to create an ebook that you can read in an evening and still impart tons of knowledge.
And so "Next-Level Database Techniques for Developers" was born.
EDIT: There are 10 sample pages (images) but on Firefox they are so small you might not notice them. The pages are in a row flexbox container which on Chrome overflows with a scrollbar but on Firefox scales all the way down to fit everything in view at once. Please add "min-width: 45%" in addition to the "width: 45%". Accessibility would also require links to the textual versions.
Let me give you an email in exchange of that bag of tricks.
Out of curiosity: what’s happening with the email? ( out of honesty: you will get my spam ridden gmail ;) )
Fixed
Anyway thanks, it's great.
Columns is misspelled on p33.
You may wish to run a spellcheck to find the others I didn't.
My disposable email I used to sign up has already been nullrouted. Rather than tit-for-tat collecting PII, why not just publish it to the whole web without the extra hoops? I'd have already sent you a PR in that case with more copy edits.
It's amazing every time how much load a properly configured database can reduce.
Especially the tips for optimizing indexes are very good. "Partial Indexes for Uniqueness Constraints" is my most favorite.
Edit: Super power here is setting up a 1Password Identity (or whichever tool you use, hell, even a snippet) to auto fill junk email in when signing up for stuff vs not-junk email. I have three identities. One for work, one for personal, one for junk. Makes this stuff super easy and fast.
For example, see: https://www.npr.org/sections/money/2012/07/13/156737801/the-...
Other people do value their time, therefore it's not free for them.
Average person on here views those hours as billable if they were to do it themselves, when they make decisions about what to do, or alternatives (opportunity cost).
Maybe he should charge them consulting rates for this PDF (and not take their -- correction: an -- email. The horror).
It's only because this is HN that it's even a discussion.
I would rather use the term opportunity cost.
Maybe OP can also put a donate button for people who don't want to provide their E-Mail and get the book.
Thanks a lot, tpetry!
I've watched that last part unfold on many occasions. Usually I'd be brought in because the developers have done everything down to "copying the data to denormalized tables[0]" to try to sort out slowness. Most of the time, just "blindly investigating the schema" will turn up something frightening that the ORM did, or a mess of inappropriate indexes. Two indexes on a table used by nearly every query in the database caused 30 second requests to yield sub-second results in one case[1]. I'm never willing to walk in and promise that, but I can't think of a time it hasn't happened when similar circumstances were presented to me.
So if you're dragging your feet about learning SQL, take this as my encouragement: it's one of those things where the rewards come quick and the effort is far less than you probably expect.
[0] ... with a broken sync process that has to be run carefully b/c it hammers the already over-sized database every time it fires.
[1] If memory serves, it was an account table ... used a GUID between the app and the database, but primary key was an integer auto-incrementing field which was used as the FK to other tables. All I remember was adding a unique index to the GUID field and including the e-mail address/name columns which were included in every query. Ran the fix in production and it felt like "the dam broke".
I have a lot of similar stories and I you are absolutely right to encourage people to learn the basics, at least (looking at you, indexes and perf tools).
We're talking about having our cpu hitting 80-90% and rising internal temperature to 70-80C, while executing a task thats normally performed tens or hundreds of times during the workday.
A couple of carefully planned indexes, a bit of sql shuffling, is all it takes sometimes.
The upside of working with cheap bare metal servers is that you catch these things early on (5 concurrent users and your server is toasted). Fun times.
Or do you just mean using indexes basically? I'm just not sure how many unknown unknowns I have wrt sql.
1. Trace your application, so you know which query is running slowly in production.
2. Using this exact query, run `EXPLAIN ANALYZE` or whatever your RDBMS equivalent is.
3. Read the output, see which step is taking the slowest. Use google to help.
4. Google-fu until you find out which index might help you.
Over time, (3) and (4) requires less and less Google, because there's really only a few common cases that give you 100% of the speedup in 80% of cases.
Once you know this path to improvement exists, it's trivial to progress down it habitually. The `EXPLAIN ANALYZE` output looks like Greek at first, but quickly becomes as familiar to parse as a compiler error, etc.
Archived copy: https://web.archive.org/web/20221202231259im_/https://sqlfor...
Having no email-wall would probably result in fewer registrations. But I do wonder if you had all the pages available -- meaning they would be indexed by Google and show up in search results -- with a subscribe to my newsletter button, if that would have a comparable number of registrations because you would have more people seeing the button? And they might be potentially higher quality registrations, too, if you want a community.
If your end goal is to share your knowledge then making the entire book public is probably the better option.
In short I'm just confused what the goal of the email-wall is!
Instead, it advertised free, then there is the wall. Like many others, I feel like I've been drawn to a false promise.
I totally understand the author can keep the book behind whatever wall he wants. The title could have been "I wrote a book about ...". And then in the site, "subscribe to get the book".
Also is a good way to weed out people who want just a 1-way relationship. I, for one, wouldn't care about not distributing my knowledge to people who aren't even willing to drop their email in exchange. Those people want something but aren't willing to give me anything - that feels really greedy.
Building an audience is incredibly difficult. People who don't want to be in my audience - I'm totally fine if they don't get access to my stuff.
(Also, one of my favorite techniques along the lines of your Lock Contention example: https://www.enterprisedb.com/blog/what-skip-locked-postgresq... is an amazing way to have a foolproof work queue without introducing things like Redis!)
Automatic no.
I can skim the chapter titles and get a pretty good idea of exactly what value there is. I'm not sure what's holding you up.
To me, the reader, what value does sharing my email or it being in The incredibly less flexible "ebook" format have?
It seems pretty self-evident that they wish to exchange something of value for something else of value. This is a pretty common activity among humans.
Unfortunately, as we see here, "instead, why don't you do even more work to change it to my specifications and then give it to me for free" is a common counteroffer.
Don't forget you don't owe these guys what they're asking for. You've done the work to share your knowledge, they can do the work to gather it.
While several chapters have mildly interesting titles, what I've come used to from these kinds of offers are mostly just rehashed blog articles from other sources. I remember one extra special case about an Elixir "book" that pretty much just copy-pasted the official getting started guide.
Generally speaking, these kind of hurdles don't inspire confidence in the quality of the content.
I haven't offered my definition of value. I just said that you can clearly determine the value to yourself by reading the landing page, it has the relevant information required (besides actually reading all the content).
It just seems like you're applying a very narrow view of what can be considered "value" here.
We're not discussing the values inherent in privacy concerns, we're discussing the value of the book, and whether or not you can guess at its value before you give the guy your email.
You're talking about something else.
Author is offering their work at a given price. That price is email. It may be worth it to you or not. Requesting a pirated copy of it without paying the price is not something I encourage,given so many of us here are well to do knowledge workers whose live being depends on people paying for our work.
(Not to mention, it's same or less work for you to create a temp email account, vs somebody else doing the work of signing up, sharing their email, and uploading and hosting content for your convenience). Yes yes information wants to be free and all that, but this is just lazy :-D
HN should have a tag for walled contents.
I think on HN a good assumption is posters want to discuss, to get feedback. Also not a bad assumption the notion of temp email will be news to absolutely no one at all here.
In this case, the value was made pretty clear in the homepage.
I was happy to only have to exchange my email for what appears to be a very high quality resource - the author is either extremely generous or undervaluing their knowledge!
Providing an email address seemed like a fair trade.
If you’re in the US and filing taxes as a employee I think you’d just sum up the book sales and stick that under Other Income. If you’re already filing as a business or self employed, just roll it in no? Of course, other countries are available.
Anyway, I’d happily pay a few bucks at the very least for this. If it’s useful, it’s going to help my own income. If I see people who maybe can’t afford a few bucks can get it for free, I’ll be even happier to pay.
Thanks for writing it!
I also can't C&P from your pages as they're images, but Ghost Conditions Against Unindexed Columns has '... AND type = in (3, 6, 11)' - is that right or did you mean 'type in (...)'. It also talks about multi-col indexes as being more useful in some cases, true, but very elementary.
This is good and well done, but please don't oversell it.
If you ask me to give you my PII then it's not free, is it?
Are you not aware how many "free ebook" spams are being sent around, usually from disreputable SEO people begging you to link them from your site? The fact that you registered your own domain is another deep red flag. Clearly there are ulterior motives here aside from "I want to help the world by putting our a free ebook".
You wouldn't be OK with the New York Times writing that Putin died of a heart attack when it's not true. Why would you be OK with this kind of deception then?
If I click on your link, I took a leap of faith on you. If I then find out that you lied to me, you made my day worse and innocent bystanders like the next guy who actually did have a free ebook will get take the damage.
He could have truthfully said: Show HN: Ebook here but you'll have to enter an email address. Then I wouldn't have clicked and we wouldn't be having this discussion now. I suspect the link wouldn't have been upvoted enough to appear on the front page either.
Also note that if I use a burner account from some spam catching service, I'm externalising my damage on to them. They might be OK with that but it's still shitty behavior on my part. So I don't use throwaway accounts. It's a moral thing. You don't litter in the park. You leave it cleaner than how you found it.
All you had to do was close the tab and move on. I can't imagine getting through life making this big a deal on such a minor inconvenience. Good luck out there.
It's unclear why. If anything, I would expect the more extensive text in the "book".
At any rate, it starts to feel like a wild goose chase after a while and my expectation is that I'll have to fill something else out or watch a ton of ads before being show fluff content if I click on a link in a book that I had to sign up for newsletter to download....
I wouldn't know though because I'd rather whine about it here than actually follow the link :)
Tpetry, I get the idea that you don't want to give away the book outright. That is fine. Some people do that, but not everyone, and it's ok if you don't. But please, don't put us through this nonsense. Just charge money for the book, and make it so that people who pay up get everything in a single download, no subscriptions, no upsells from individual chapters. I am interested in such a thing, enough to probably be willing to buy a copy. Thanks for your consideration.
1) movie_actors (movie_id, actor_id, order_index)
2) movie_watchlist (movie_id, user_id, created_at)
3) movie_ratings (movie_id, user_id, rating, created_at)
I know strange question, but most guides suggest all these table should have autoincrement id column
LE. Almost nothing is applicable for MS SQL; some stuff is built into T-SQL, so there is no need for tricks, others have completely different solutions.
For example the first recipe will not work as expected with out a multi-column unique index (specifically the MySql example).
I feel that the preexisting knowledge required for such examples does not align with the stated target audience for the book.
And I will look at the stats tomorrow and send everyone the PDF who didn't get it because of the false spam classification.
Only critique is that it would be super useful to include some example query results for each section so show the effect.
I'm fascinated by DBMS each day I use them.
The offering is called an eBook but I'm not seeing any way to download a local copy as PDF or otherwise.
Maybe it’s been added in the face or HN grumpyness? ( tbh : I would not have give anything without those extracts, so your comments in on point )
Also, SQL databases are one of my favorite tech topics. Postgres, especially, has tons of cool features (example: lateral joins.)
While it does look really handy and well put together, unfortunately none of the tips in the book that I read before giving up are useful to someone using mssql
-- MySQL
SELECT * FROM example WHERE NOT(column <> 'value');
-- PostgreSQL
SELECT * FROM example WHERE column IS DISTINCT FROM 'value';
That doesn't seem equivalent?NOT(column <> 'value') seems to be wrong
Did you mean
NOT(column <=> 'value')
?
Red button: Give me $5
Blue button: Give me your email.
Everyone's happy! Sharing the results would be an icing on the cake.
And I will look at the stats tomorrow and send everyone the PDF who didn't get it because of the false spam classification.
Thank you for the free book.
I don't have any of the extended filters, but it is a small size reduction with the default load:
$ ./pdfsizeopt next-level-database-techniques-for-developers.pdf
...
info: generated object stream of 7399 bytes in 224 objects (9%)
info: generated 387518 bytes (89%)
$ stat -c '%s %n' next*.pdf
435483 next-level-database-techniques-for-developers.pdf
387518 next-level-database-techniques-for-developers.pso.pdf