Article · 2 min read · EN
A day on my main Telegram account
I put tg on my main Telegram account and left it running for a day. tg is my Telegram CLI: it keeps your chats in a local SQLite database, so you or your agent can search them and run SQL. The daemon had never run on my account before. An agent wrote down tg status every five minutes, which is where the chart comes from.
In 36 seconds it found almost 3,000 dialogs and queued the history of more than 2,500 chats: DMs and small groups in full, big groups and channels only on request. Then it just kept downloading. The laptop slept at night, and the daemon never crashed or restarted. After 23 hours the database held 822K messages, 1.2 GB on disk.
The interesting part is why it took that long. Telegram never once asked it to wait while it downloaded history. The daemon spent 92% of its active time waiting on its own: by design it makes one call every three seconds, to be safe. On a test account Telegram starts throttling at about one call per second, so tg was about 3.5 times more polite than it needed to be. Next I'm making the pace adaptive: start faster, back off when Telegram asks. By my estimate an account like mine would then sync in 3–4 hours of active time instead of 11.
Search is already fast: 40–75 ms per query over 290K messages, and prefix queries like word* match every form of a word.
The day also found bugs you don't see on test accounts. After the laptop woke up, the daemon reconnected but didn't catch up, so one group was missing four overnight messages until a restart. Some history pages lost their senders, so about 9% of messages showed no name in search. And usage stats delayed every command by half a second. All three are fixed in 0.9.0, out yesterday. It also makes tg status show how much history is left and roughly how long it will take.
And what a real account looks like: 1,112 of my chats have ten messages or fewer, while 19 chats hold almost half of everything.
brew install neoromantic/tap/tg
