Your first job can be a grind. Many of us start out in low-level gigs that we never thought we’d have to take, maybe because the job market is tight and we need to make ends meet so we can move out of our parents’ basement. For the lucky ones, the first job is temporary and a stepping stone to something they love, but for others it can be the start of many years of a career they hate.

At least they have your health, right? Actually, it looks like the consequences of their unhappiness at work may affect their physical and mental well-being – and perhaps sooner than you might think.

An analysis by Ohio State University’s Jonathan Dirlam and Hui Zheng, presented this week at the American Sociological Association’s annual meeting, suggests that job satisfaction in your late 20s and 30s appears to be linked to your health in your 40s.

The researchers’ data came from 6,432 Americans who participated in the National Longitudinal Survey of Youth in 1979. Through the years, the volunteers ranked how much they enjoyed their jobs on a spectrum from 1 – dislike very much – to 4 – like very much. They also reported back various health indicators.

Dirlam and Zheng found a striking link between people who were less satisfied with their jobs in their 20s and 30s and those who had health issues in their 40s. That may seem intuitive given that people tend to spend eight or more hours a day at work, and dissatisfaction at work can create a lot of stress. As has been well documented, stress can have physical manifestations.

Among the specific health effects the researchers noted among the less-than-happy group is that they were more depressed and worried and had trouble sleeping.

One interesting aspect of the analysis is that the health effect was not related to people’s happiness with their very first job or jobs, but with how their work happiness changed over time. Those with increasing satisfaction fared better than those with declining satisfaction, in terms of their health.

Dirlam, a doctoral student in sociology, explained that there appears to be a “cumulative effect of job satisfaction on health that appears as early as your 40s.”