I sometimes have a problem to solve and an idea on how to solve it, but my own solution seems far from optimal. Should I put my own solution into the question, because I'm looking for improvements on that, or should I instantly-self-answer with that probably bad solution in order to properly split questions and answers?
You can probably use your own judgement in these cases: clarity is what's important.
There are 3 potential options: include your solution in the question, write it up as an answer to your question, or post it on Code Review.
Your question can include examples of what you have tried, so if your answer is farily small and not too specific to your case you can include it to demonstrate what result you're looking for. But if your potential answer is quite large and indepth and you feel that it distracts from the original question then you can instead add it as an answer* and refer to it from your question - specifically asking people to provide something better. If no one can then your answer is the best and as such should be the correct answer anyway.
If your question and solution instead amount to more of a "I've done this but I'm not sure if it's the right way to go about it, please could you check it for me" kind of question then it's a better fit for Code Review.
*provided that it actually does solve the problem as stated in the question
You can add your solution in your answer as an example of what you have tried. And if you state the problems with that solution, the other users have more information to give a useful answer.
Don't put your (partial) answer into the question. This may not make a difference at first, but once there are better answers, you bad answer would be still be shown at the top if you had put it into the question.
Instead, write your bad answer as answer (with a disclaimer that you are aware that it isn't optimal), and let it be sorted to the bottom by the site.