Ds was like that for utnil 2y. I never found anything to help, TBH, other than making sure he didn't get constipated (which he was prone to do). But he wasn't particularly distressed about it in general. I think if he's distressed you ought to take him to the GP.
Olive oil helps keep things moving along. Not by lubricating, but by stimulating the gut to move IIRC. We used to give ds olive oil, whether by cooking with it or just by adding a few drops to his food once it had been cooked. Raw is better than cooked. I also cut down on wholewheat, which is totally against the usual advice, but I felt that (a) wheat bran can be quite irritating, and (b) he didn't need extra bulk in his poo as it was generally soft already and extra bulk just made there be more to have to deal with. Cutting down on red meat seemed to help as well - I didn't exclude it, just only had it max 3 times a week. I also never gave him to meat meals in one day.
All these things never solved the problem, they just made it a bit easier to deal with. It just went away completely on its own after an episode of constipation during which I encouraged ds to sit on the potty, in his nappy, while he tried to poo, as I hoped that the posture would help him. Afterwards he always insisted on sitting on the potty to poo. He still strained terribly and was totally overwhelmed by the urge to poo but didn't always pass much if anything.
He's still like that at 5, but better able to resist the urge to go. If the urge fades then he knows he didin't really need, and if it doesn't fade, or it returns then he tries and usually manages a poo. It's always seemed to me to be that he didn't know when the urge was real or not. We as adults can often say to ourselves 'Hmm, I'll need to poo soon' and wait until we really have to go, but I wondered whether ds couldn't make that distinction, and trie dto poo whenever he felt the vaguest need. But, like I said, he would be totally overwhelmed by the urge, so that doesn't quite work either.
Anyway, I hope that something about this sounds familiar to you and that you'll be able to use some of it!
But it does seem to me that if he's distressed about it you ought to see the GP.