Fragmented Sleep
Combining SQL learning & personal diagnostics.
SQL is something I needed to learn thirty years ago, but there’s no time like the present. The best exercise is something that matters, in this case my fragmented sleep.
These were produced using my Garmin Fenix 6S, a Python script that converted their SQLite3 data to Postgres, and I’m developing in Antigravity, using a mix of Google’s Gemini3 and Anthropic’s Sonnet4.5.
Attention Conservation Notice:
This is a motivational piece for those of you eyeing Antigravity with distrust. Be skeptical, put systemic guard rails around it, then be even more skeptical. Using it is the pet owner equivalent of taking your husky for a walk to escape your Bengal cat who’s tearing the house apart. That being said …
Heat Maps:
The top quality sleep data collection began 4/1/25.
But I have biphasic sleep about 30% of all days. This is detected using the Garmin’s heart rate and “stress” data. Being briefly wakeful in bed is normal, these are sleep periods separated by significant active & out of bed time.
And 10% of days involve triphasic sleep - in most cases that’s biphasic plus eating triggering an MCAS episode.
But there was a major change roughly in the middle. There are 242 days of data, the first 126 were before I began MCAS treatment, then 116 days after that. I didn’t do this intentionally, but it’s a really nice dataset to examine.
And I think this is the ultimate multi-heat map infographic. Now we can see the total sleep minutes per day as well as per hour for each of the sleep phases. The big surprise here is the sleep durations on MCAS days - I’ve always felt these were days with a lot of sleep, but the MCAS average is 310 minutes, while non-MCAS days are 317. My sense of things before this study was that I had much more sleep on bad days.
Development Results:
This is a topic I know well, but look at the time from conception to completion - 73 minutes. This involved two skills I do not have (SQL, Pythonic HTML formatting), it’s almost entirely Gemini3 doing the work. Keep in mind this is just the presentation portion of the task. Replacing the simplistic Garmin “you sleep once per day” reporting with something that used biometrics to differentiate between “briefly woke to rearrange pillows” vs. “got out of bed and did stuff” took all of the prior evening.
Doomscrolling:
My iPad is mounted on a stand so I can use it while laying in bed and it’s almost never out of its spring loader holder. While theoretically for reading via Dropbox or Kindle, the lion’s share of usage is Brave browser for YouTube. There’s also a big Prime Video queue, but the ability to app switch means in practice this doesn’t get viewed. If you’re getting that anxiety/depression vibe here, you’d be right on the money.
I started on this because there’s a little problem up above - 116 calendar days elapsed between MCAS treatment beginning and the data I used in this article. The final triphasic sleep heat maps only show 40+66 = 106 days. Did I really not sleep almost 10% of those days? That is NOT out of the realm of possibility, but to sort out what’s happening I need to know when I was using the iPad.
I first mentioned Pi-hole last spring in Avoiding ADINT and this is something that’s pretty much always on in my hut. My browsers all have the sort of hardening you see here - Adblock, Decentraleyes, Privacy Badger, and uBlock Origin Lite, but the best defenses are layered defenses.
Making a table in Postgres with the timestamps when I was active? Six minutes. Figuring out why the Pi-hole Sqlite3 database was both time shifted and delayed? Getting the actual log, pulling just the iPad, and formatting it for input? The first file associated with that effort is stamped 16:58 and the result I wanted says 18:47.
That’s 109 minutes of hacking around on my DNS server in order to do a six minute programming project, which is pretty classic data science. Getting clean stuff takes FOREVER, then reaching the intended objective is near instantaneous.
Just as I got the Postgres loader Gemini3 cheerily reported that I would need to sit on my hands for three hours before using it for anything else. I could switch to either Claude Sonnet or GPT-OSS, but having done the bulk of my Antigravity work with Gemini3, the others just “feel” funny. Claude is skilled, but goes at things in a different fashion. GPT-OSS makes me use driving words when I see the stupid shit it gets up to scrolling by in the little status window.
(Some time passed and I just fixed it the old fashion way - with a mix of patience and Unix command line tool chains.)
Conclusion:
Things like this are treasure when one is chronically ill. If you’ve never had a long term sickness, you wouldn’t know these things, but this is my ground truth, and I think it’s pretty universal.
My body is a problem I learned to tune out a long, long time ago.
Even when trying to pay attention, even written logs, I will miss things.
It’s normal to respond to suggestions dismissively, because no energy to pursue.
If someone is unwell, you MUST seek permission before sharing information. It is very common for people fighting chronic conditions to simply be tuning out, to have no energy to put towards another attempt at a solution. Fail to respect this and you lose any chance you had to help.
I am observant. I practice mindfulness in daily life. I took notes as I hunted my condition. I periodically searched for literature on my issues. I joined support groups.
And all that paled BADLY in comparison to what an LLM, which could hold all of my history in its memory, accomplished in a few weeks.
Coda:
This is TOO easy … looking at sleep vs stress. This took about fifteen minutes with Claude Sonnet 4.5.










