My boss (and, actually, his boss too, which is the company general director) are generally quite good.
But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do.

Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. 

This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...)

How can I convince them to stop "doing", without being rude, annoying, or worse?
(he is still my boss, after all :) )
I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation.

---

EDIT:
Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc.

I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
Is this actually a problem?
===========================

I fairly recently had this exact experience. My manager was considerably more interested in doing day to day work than managerial duties, such as:

* [Caring about resource management](https://workplace.stackexchange.com/q/9128/2322)
* Effectively working with other managers
* Making our team's project work [visible](https://workplace.stackexchange.com/a/11818/2322) to others

I had many conversations about this very subject, to the point where I (and others on my team) were told to effectively "just worry about your own position and not what others were doing." Well, our main problem was that my manager was *not* effectively leading the team and the key obstacle to our project being successful was in fact our manager not doing the leadership/managerial duties.

Your concerns are absolutely valid.

Some things to keep in mind:

* Some people are managers because of circumstance, rather than desire/ability. Many a manager gets there because they happen to be the most senior individual contributor even though they may be considerably more effective as an individual contributor than manager. Or other reasons unrelated to their ability to manage.
* Some managers never accept the idea that they are managers and not worker bees.
* Management offers considerably more ambiguous "what did I do at work today?" answers. For many people who like checklists and feeling accomplished, this can make work very hollow/meaningless
* Management is a huge step outside a comfort zone for many people. The longer someone has been an individual contributor, the more difficult it can be.
* They might be totally aware of this issue but having a really hard time doing anything about it.
* This becomes more important the larger a team is. If your boss has 3 direct reports, it's less important. But if you have a team of 10, your manager doing day-to-day work is considerably more problematic.

What can you do about it?
=========================

Don't focus on the things you can't change (ie your manager's tendency to do work he shouldn't do).

Focus on what your manager is *not* doing for you and your team. Are you not getting the resources you need from him? Is your team not working together effectively? Do you need a team meeting/etc?

If you don't have regular 1/1s because of your manager is too busy doing day-to-day work, don't say "you should stop doing day to day work so we can have 1/1s" but just approach it from the "can we have 1/1s? this would be helpful for x/y/z reasons."

If your team needs more visibility, approach it from the perspective of, "hey, what do you think we can do to get our team more visibility?"

In addition to this, be sure to thank your manager for the effective managerial work that he does. People respond surprisingly well to positive feedback. Continually reinforcing your manager for managing is a easy, non-threatening way you can encourage them to manage rather than do day-to-day work.

---

This [answer](https://workplace.stackexchange.com/a/11606/2322) to a related question is quite informative.
I'm kind of latching on to one idea that may not actually be relevant, but one thing you mentioned was the difficulty of giving up "getting my hands dirty". This could be true, or it could be that he just fails at delegating tasks once in a while. Various reasons could be at play for not delegating:

* He's uncomfortable with delegating tasks(or otherwise hasn't gotten used to it yet)
* The tasks he ends up doing are close to his experience, so he sees himself as the obvious candidate
* He really does like getting his hands dirty.
* Doing those tasks reminds him of what he's passionate about.
* He wants a break from his other duties.
* Etc. He certainly isn't the first person to move up and miss doing the grunt work.

If you end up in meetings where your boss says things like "Today I'm going to try doing `<drone work tasks>` to help you guys along", then whoever has the most experience with those drone tasks could speak up and ask to do them instead. 'Ask' is the key word in the last sentence. Don't *tell* your boss you're going to do the task - *ask* him. It's important that he sees he has the power to make the decision. Eg. (You say) "Oh! I've been working on the SQL queries lately and have a few scripts that help me. I could do `<the thing>` and have the report in your e-mail by close-of-business today. Would that be ok with you?" 

The key is to make it really easy for him to say 'yes' to you - stack the odds in your favor however you can(you're not busy, it'll take you no time at all, you have the tools ready to go, you won't miss your deadline(s) for anything, his time is better spent elsewhere, etc).

By taking initiative to do these tasks, you(as a team) show him you're willing to step up for him to get the job done, and it's a way of easing him into delegating tasks to people. He may be good at delegating big-picture stuff. He's not stupid enough to think he can do all the work himself. But these one-off situations are trickier, especially when you remember being able to do these kinds of things in a few hours.

**Personal anecdote(I've made my point by now, the rest is fluff):** 

I'm a very non-confrontational person and I'm also a junior software developer. I was given the reins of one of our R&D labs, which may sound more grandiose than it really was - I 'managed' 2 people's time in the lab(both working part time usually, sometimes full time) for roughly 4 months. 

At the start most of my time, roughly 80% weekly, was on my main project, so I had ~8 hours per week (2 hours per day Mon-Thurs) to deal with the R&D lab. I wasn't comfortable with telling people what to do, but I really had no other choice. If I hadn't been thrown in the deep end and had to 'figure it out' so abruptly with the time constraints that I had, I think the transition would've been tougher and I'd be more prone to helping with tasks. To say the least, it was *very* difficult to not stick my hands in the code.

It also helped that the people I 'managed' were two coworkers I had worked with extensively who were both smart and trustworthy. When I gave them tasks, I was certain they'd ask questions if they got stuck, but otherwise they would finish them and not waste time.

Your post doesn't give too much detail, but the delegation thing just got stuck in my head since I went through that last year. If your boss is a newly-made/recently-promoted boss, perhaps that's what he's going through.