i think it's wise to do the research first. i only wish i could follow my own advice. what i find i do is start the story and have an idea as i write. too often i discover that that idea doesn't fit at all where i want it to, or, even worse, the research doesn't solve the problem because it doesn't have the 'right' facts i'm looking for. usually it's a technical problem. typically it's something stupid like how houses were plumbed for gas lights. or is it the right carriage, or would the maid wear a corset, and shoot me now, please. one thing that absolutely drove me mad was finding out what kind of police/constabulary force would be around in 1693 new england area.
so, i can't give more props to doing research ahead of time. one prompt that turned into a book involved a diamond. i forget exactly how i came about the name, but the diamond also turned out to be a somewhat famous ship, perfect for the story. it didn't hurt that the ship was considered cursed. it even had a steel hull, very unusual for its time. so i used the ship to sail overseas where it docked with an underwater mechanism ~ the boat was a key, an electrical conductor that opened up the island's main door and turned the ancient machinery on. i mean, what else would the ship with a steel hull be used for, i ask you? but, i'd never had had that idea (which i think is pretty cool) if i hadn't researched it first.
and the thing with research is there's sometimes a fact involved that you wished you'd known earlier. what i'm working on right now had a vague year to it until i was researched victorian dresses, found this thing called the contagious disease act, and want to use that. it also gave me a specific year, which in turn nailed down the style of dress to use.
so, resurch good, ug.